[All]
Why can my Win32 Delphi application not call a COM registered C#Builder created C# assembly, whereas if I Visual Studio it works?
Utdrag: Why can my Win32 Delphi application not call a COM registered C#Builder created C# assembly, whereas if I Visual Studio it works?
There are a few things to remember:
1)����� C#Builder does not mark the C# assembly as ComVisible by default, (this is actually a good thing otherwise EVERYTHING in assembly will be visible as a COM object) you CAN mark the whole assembly as [assembly: ComVisible(true)] in the AssemblyInfo.cs �OR better yet just mark your class as ComVisible and keep [assembly: ComVisible(false)] AssemblyInfo.cs. This is exactly where C#Builder and Visual Studio differ, as Visual Studio marks the WHOLE assembly as ComVisible by default. Here is an example where just the class itself was marked as ComVisible.
�
[ComVisible(true)] //<<<<<<<<<<<<<<<<<<<<<<<<<ADDED...
[ClassInterface(ClassInterfaceType.AutoDual)]
public class Class
{
public Class()
{
}�
�
�
2)����� The next thing to remember is when registering the assembly with the �regasm� tool is to specify the /codebase option, as follows "regasm CSAutoClassAsmbly.dll /tlb /verbose /codebase".
3)����� Then all that is left to do is to import CLR�s system.tlb and mscorlib and the typelibrary (in this case CSAutoClassAsmbly.tlb) which we generated in 2)