views:

27

answers:

2

When i add a .dll file as a reference in C# application it shows an error :

A reference to the "....dll" could not be added.Please make sure that the file is accessible and that it is a valid assembly or COM component. ILDissassembler says there is no valid CLR header so I try to register it using regsvr32 and that gives me another error: The module "" was loaded but the call to DLLRegisterServer failed with error code '0x80004005'

I am using VS2010 ultimate on a 64bit windows 7 machine. What could be the problem?

Thanks for any hints/replies

A: 

You can add a DLL (or EXE) to a project only if it is a .NET assembly. If it's not you will see this error message.

regsvr32 also makes certain assumptions about the structure and exported function in the DLL. It has been a while since I used it but it has to do with registering COM servers so certain entry points need to be available. If regsvr32 fails the DLL doesn't provide those entry points and the DLL does not contain a COM component.

You only chance for using the DLL is to import it like any other non-.NET binary, e.g. when you use certain Win32 APIs. This MSDN magazine article might be helpful.

John
A: 

I used dependency walker to check out the internal references the dll was having. Turns out it was in need of the VB runtime msvbvm60.dll and since my dev box doesnt have that installed I was unable to register it using regsvr32

That seems to be the answer to my original question for now.