Couple of things to remember:
1. In VS2005, a class library is by default set to hide all its types from COM.
This is set using the attribute ComVisible in the assembly metafile 'assembly.cs'
2. To use the default application configuration mechanism, the .config file should be named after the hosting EXE.
For example, say we have a .NET library 'myLibrary.dll' with a config file 'app.config'.
When this library is used from a COM client EXE 'Server.exe', the library will by default look for a config file 'Server.exe.config' NOT 'myLibrary.dll.config' ...
3. Best to override the default ComInterop behaviour to:
-fix GUIDs of interfaces and classes. This is for consistent registration.
-for VB clients, use Dispatch only interfaces.
-Set classes to have no interface generated, instead define the interfaces separately.
4. Interfaces should be defined in terms of only interfaces and value types, not classses
4. Only expose public types as needed!
Microsoft high level guide:
http://msdn2.microsoft.com/en-us/library/7fcfby2t(VS.80).aspx
Detailed guide to exposing .NET types via COM. Has very good tips for exposing .NET to VB6:
http://www.15seconds.com/issue/040721.htm
1. In VS2005, a class library is by default set to hide all its types from COM.
This is set using the attribute ComVisible in the assembly metafile 'assembly.cs'
2. To use the default application configuration mechanism, the .config file should be named after the hosting EXE.
For example, say we have a .NET library 'myLibrary.dll' with a config file 'app.config'.
When this library is used from a COM client EXE 'Server.exe', the library will by default look for a config file 'Server.exe.config' NOT 'myLibrary.dll.config' ...
3. Best to override the default ComInterop behaviour to:
-fix GUIDs of interfaces and classes. This is for consistent registration.
-for VB clients, use Dispatch only interfaces.
-Set classes to have no interface generated, instead define the interfaces separately.
4. Interfaces should be defined in terms of only interfaces and value types, not classses
4. Only expose public types as needed!
Microsoft high level guide:
http://msdn2.microsoft.com/en-us/library/7fcfby2t(VS.80).aspx
Detailed guide to exposing .NET types via COM. Has very good tips for exposing .NET to VB6:
http://www.15seconds.com/issue/040721.htm
Comments
Post a Comment