Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does regasm.exe register my c# assembly with the wrong GUID?

I've got a c# assembly which I'm invoking via COM from a Delphi (win32 native) application.

This works on all the machines I've tested it on, except one.

The problem is that the Delphi application gets "Class not registered" when trying to create the COM object.

Now, when I look in the registry under HKEY_CLASSES_ROOT\DelphiToCSharp\CLSID, the GUID listed there is not the same as the assembly Guid in AssemblyInfo.cs. It should be the same - it IS the same on all the other computers where it's installed.

I have tried regasm /unregister delphitocsharp.dll, and that removes the registry key. Then if I do regasm delphitocsharp.dll, the registry key returns, but the GUID is the same as before (ie. wrong), and Delphi still gets "Class not registered".

DelphiToCSharp.dll on the working machine is identical (verified with md5) to the version on the non-working machine.

All I can think of is that an old version of the dll was registered before, and there still exists some remnant of that file which is making regasm confused.

How can I fix or at least further diagnose this issue?

like image 700
Blorgbeard Avatar asked Sep 29 '08 05:09

Blorgbeard


3 Answers

The GUID in AssemblyInfo becomes the "Type-Library" GUID and usually is not what you'd be looking for. I'm going to assume you're trying to access a class, and you need to define a Guid attribute and ComVisible for the class. For example:

[Guid("00001111-2222-3333-4444-555566667777"), ComVisible(true)]    
public class MyCOMRegisteredClass

If you don't, then the class either a) won't be registered, or b) if you've defined COMVisible(true) at the assembly level, will be assigned a guid that .NET bakes up for you.

like image 166
nedruod Avatar answered Sep 20 '22 05:09

nedruod


Maybe you have an old version of the assembly somewhere? Maybe in the GAC? Regasm is probably picking that up and using it.

like image 28
1800 INFORMATION Avatar answered Sep 21 '22 05:09

1800 INFORMATION


Most probably you have a copy of the same (old version) dll somewhere on your system, search disk for copies of the same file and remove (backup) them manually before registering the new copy.

like image 20
Drejc Avatar answered Sep 19 '22 05:09

Drejc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!