What does the Setup Project do for .NET COM?
Ok, imagine the simplest solution in Visual Studio 2008 with Framework 3.5 (OS = Win XP) where I added a class library. Then I added a COM class. This COM class is so simple that it only provides one function:
Public Function SayHello () As String Return "Hello". End function
I created this class library which created the .dll and .tlb. I can see the .tlb in the VB6 Applications Links window (which is on the same computer), so I link to it. I call SayHello, run it and ... "automation error".
I found an article somewhere on how to create a SetUp project and then install the .dll. After I separately installed the .dll using this customization project, the COM component works as it should in my VB6 application.
Ok, now for my question ... WHY ?! Can someone please explain to me what the setup project is doing that I have not followed.
PS: Just to figure it out, it worked fine with VB2005 and Framework 2.0 ... But now I can't make this simplest example project work.
If you do not explicitly specify the UUID for the assembly type library and all classes and interfaces exposed by COM, VS will automatically change them on every rebuild to prevent so-called "COM hell" (registry pollution with UUIDs).
Before compiling, VS unregisters the previous version of the assembly, then compiles the assembly and registers the new assembly. If the consumer (your VB app) was not immediately recompiled, it will now not be able to use the assembly because there is no registry data in the previous version of the assembly and the corresponding type library.
To combat this, you need to explicitly specify the UUID for all COM-affected objects, and then you will need to fully maintain binary compatibility.
a source to share