views:

40

answers:

2

I have a simple C# class with COM attributes:

[ComClass("1DC7B465-49FA-4ad1-893E-C19657E1ED25", "F97459E6-AB37-43e6-AC57-6AE5F9A9A835", "BD9F01C7-162A-4f95-9398-C126C152B965")]
    [ComVisible(true)]
    public class Class1
    {

    }

I need to use this class from VB6 application. It works well until I change AssemblyVersion of .NET dll. Then VB6 doesn't create C# class instance (throws an ACtiveX exception) until I recompile it (VB6 application).

It is interesting that I do not need to recompile Class1 if it is written in VB.NET.

What is the difference between C# and VB.NET here? Is there any way to make C# behave like VB.NET?

+2  A: 

The most likely difference is between the standard AssemblyInfo.cs and AssemblyInfo.vb generated by the two project wizards. You can compare these two to see if any of the assembly level attributes differ. Btw, I would bet on the version attributes.

Franci Penov
A: 

I looked into assemblies generated by C# and VB.NET compiler and found out VB.NET generates Guid attribute in addition to ComClass attribute. C# doesn't do it. So I have added Guid attribute to C# class explicitly and it solved my problem.

Idsa