We have a .NET exe (.NET 3.5, VS 2010 SP1, VB.NET) project that is COM visible. A VB6 application uses CreateObject to create an object from this assembly.
This works without any problem if we do not sign the assembly. If we sign the assembly (with a pfx-certificate), CreateObject fails with the message
Can't create Object "Our.ClassName"
Unfortunately, there is no entry in the event log. The .NET exe can be started without any problem so all dependencies should be in place. We've also enabled .NET binding logging, but it does not write anything when CreateObject is called (so we suspect that the creation fails before the assembly is loaded).
We've tracked down all changes, the only difference that matters is whether the assembly is signed or not. Also we've tried different certificates, but the behavior doesn't change.
Has anyone experienced this behavior before and can provide a solution? Are there any ways that can give us more information about the failure?
Another close look into the registry revealed, that the reason was a change in the version number of the assembly. Some time ago, version 3.0.0.0 was registered - obviously in a version without a strong name. After some changes in the build process, the version was reset to 1.0.0.0.
REGASM
registered version 1.0.0.0 in the registry, but (of course) failed to remove version 3.0.0.0 under the keyHKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Classes\CLSID\{00000000-0000-0000-0000-000000000000}\InprocServer32
in the registry when we tried to re-register the assembly.CreateObject
uses the highest version when resolving the assembly and thus acquired the assembly reference without a strong name. This reference was bound to the assembly with version 1.0.0.0 (as it was not strong named, the difference in version was not respected) so that it worked correctly for a assembly without a strong name.We will reset the version to its old value in order to maintain consistency.