ComVisible

Team-Fly    

 
.NET and COM Interoperability Handbook, The
By Alan Gordon
Table of Contents
Chapter Eight.  Advanced COM to .NET Interop

ComVisible

You can specify which members of your classes will be visible to unmanaged (COM) clients using the ComVisible attribute, which resides in the System.Runtime.InteropServices namespace. To specify that a property or method should be visible to COM, set ComVisible to true as follows :

 [ComVisible(true)] public void DoSomething() { // Do something... } 

To specify that a property or method should not be visible to COM, set ComVisible to false as follows:

 [ComVisible(false)] public void DoSomething() { // Do something... } 

The ComVisible attribute can be applied to a class, structure, enumeration or an entire assembly. It can also be applied to any of the members of a type such as a method, property, field, interface or delegate. You can hide specific members of a type by setting the ComVisible attribute to false on that member. Public managed types in an assembly are visible (ComVisible=true) by default, so you don't have to do anything if you want all of your public managed types to be available to unmanaged consumers. Setting ComVisible to false on on an assembly hides all public types within the assembly. The ComVisible value applied to a specific type overrides the assembly setting, however. Therefore, you can expose only selected types from an assembly by setting the ComVisible attribute to false on the assembly and true on the types you want to expose. Only public types can be made visible. The ComVisible attribute cannot be used to make an internal or protected type visible to an unmanaged client.


Team-Fly    
Top
 


. Net and COM Interoperability Handbook
The .NET and COM Interoperability Handbook (Integrated .Net)
ISBN: 013046130X
EAN: 2147483647
Year: 2002
Pages: 119
Authors: Alan Gordon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net