اكتب تماثل و Interop مضمنة أنواع
يبدأ بـ .NET Framework الإصدار 4، اللغة الشائعة وقت التشغيل يدعم تضمين معلومات نوع من أنواع COM مباشرة في إدارة تجميعات، بدلاً من طلب تجميعات التي تمت إدارتها للحصول على معلومات النوع لأنواع COM من تجميعات إمكانية التشغيل المتداخل. Because the embedded نوع معلومات يتضمن فقط the أنواع و الأعضاء that are actually used بواسطة a مدارة تجميع, الثاني مدارة تجميعات might have very different طرق العرض of the same COM نوع. Each مدارة تجميع has a different Type كائن إلى represent its عرض of the COM نوع. The وقت تشغيل اللغة العامة supports نوع equivalence between these different طرق العرض for الواجهات, structures, enumerations, و المفوضون.
نوع equivalence means that a COM كائن that هو passed من واحد مدارة تجميع إلى another can be cast إلى the appropriate مدارة نوع في the receiving تجميع.
ملاحظة |
---|
نوع equivalence و embedded interop أنواع simplify the توزيع of applications و إضافة-زر 'Ins' that استخدم COM مكونات, because it ليس necessary إلى نشر interop تجميعات مع the applications.Developers of shared COM مكونات still have إلى إنشاء توافق أساسي تجميعات (PIAs) if they want their مكونات إلى be used بواسطة earlier versions of the .NET Framework. |
نوع Equivalence
Equivalence of COM أنواع هو supported for الواجهات, structures, enumerations, و المفوضون. COM أنواع qualify كـ equivalent if الجميع of the following are صواب:
The أنواع are كلاهما الواجهات, أو كلاهما structures, أو كلاهما enumerations, أو كلاهما المفوضون.
The أنواع have the same الهوية, كـ described في the التالي مقطع.
كلاهما أنواع are eligible for نوع equivalence, كـ described في the Marking COM أنواع for نوع Equivalence مقطع.
نوع الهوية
الثاني أنواع are determined إلى have the same الهوية when their scopes و identities مطابقة, في غير ذلك الكلمات, if they each have the TypeIdentifierAttribute سمة, و the الثاني السمات have matching Scope و Identifier خصائص. The المقارنة for Scope هو حالة-insensitive.
If a نوع does not have the TypeIdentifierAttribute سمة, أو if it has a TypeIdentifierAttribute سمة that does not specify نطاق و معرّف, the نوع can still be considered for equivalence كـ follows:
For الواجهات, the القيمة of the GuidAttribute هو used instead of the TypeIdentifierAttribute.Scope خاصية, و the Type.FullName خاصية (that هو, the نوع اسم, including the مساحة الاسم) هو used instead of the TypeIdentifierAttribute.Identifier خاصية.
For structures, enumerations, و المفوضون, the GuidAttribute of the containing تجميع هو used instead of the Scope خاصية, و the Type.FullName خاصية هو used instead of the Identifier خاصية.
Marking COM أنواع for نوع Equivalence
يمكنك وضع علامة على نوع كـ لنوع تماثل بطريقتين:
يطبق TypeIdentifierAttributeسمة إلى نوع.
جعل النوع نوع استيراد COM. واجهة هو COM استيراد نوع إذا لم يكن في ComImportAttributeالسمة. واجهة، بنية، التعداد، أو تفويضا هو COM استيراد نوع تجميع في عليها هو تعريف له ImportedFromTypeLibAttributeالسمة.