ComVisible (false) class with ComVisible members (true)

I am studying Microsoft Certification exams and I came across a situation with a class that was not ComVisible, but had methods that were. I suggested that since the class was not visible to COM, its members would not be accessible. However, apparently, the members can be ComVisible, even if the class is not.

How to COM access a member of a class if it cannot access the class in the first place?

I have never had experience providing .NET assemblies for COM. It makes little sense to me.

+3
source share
1 answer

You have probably come across a sample code in the MSDN doc page for ComVisibleAttribute. Yes, this is fictitious. The same page focuses on:

Setting the attribute to false for a particular type hides this type and its members. However, you cannot make type elements visible if the type is invisible. Setting the attribute to false for a type prevents the export of this type to the type library; classes are not registered; interfaces never respond to unmanaged QueryInterface calls.

Invalid code example.

+4
source

Source: https://habr.com/ru/post/1760209/


All Articles