Namespace: System.Runtime.CompilerServices
Building .NET Components for use by COM
.Net framework generates COM Proxies
known as COM Callable Wrapper (CCW) to be used by COM. No matter how many COM
clients consume a given managed object, .Net runtime will create a single CCW.
Write down you class and before building it, Select the
configuration form the project properties named “Register for COM interop”.
Hiding public .NET Classes from COM
To hide a class or member just use
the following attribute: [ComVisible(true/false)].
Deploying COM-Enabled Assemblies:
Check
the following necessaries before creating CCW:
1.
All class have default
constructor (no parameter).
2.
Exposed Types should be
public.
3.
Any member exposed should
be public.
4.
Abstract classes will not
be able to be consumed.
After this verification you can create CCW using Visual
Studio or using tlbExp.exe.
Compile the type using VS 2005 or the following Command-line
Csc /t:library
ComVisibleObjectCollection.cs
Create a resource script file named: ComVisibleObjectCollection.res
having text:
IDR_TYPELIB1
typelib “ComVisibleObjectCollection.tlb”
Now, to create a resource file compile the resource script
using the command:
rc
ComVisibleObjectCollection.res
And now compile the assembly and embed the resource as win32
resource:
Csc /t:library ComVisibleObjectCollection
/win32res:ComVisibleObjectCollection.res
Comments