views:

2498

answers:

3

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?

A: 

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

1800 INFORMATION
It can't be in the GAC, because my assembly is not signed. Good point though, I'll search for other copies of the file.
Blorgbeard
.Net's assembly loading does not locate the dll in as many directories as win32 does, so that can hardly be the case.
Lars Truijens
A: 

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.

Drejc
+6  A: 

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.

nedruod