Add reference to dll

  • Thread starter Thread starter ndq
  • Start date Start date
N

ndq

Adding a .dll file as a reference in C# application shows error:

"A reference to the "dll" could not be added. Make sure that the file is
accessible and that it is a valid assembly or COM component."

Does this mean that for add-reference to work, the dll has to be in managed
code or COM dll in unmanaged code?

How to tell if a DLL is in managed or unmanaged code?
 
ndq said:
Adding a .dll file as a reference in C# application shows error:

"A reference to the "dll" could not be added. Make sure that the file is
accessible and that it is a valid assembly or COM component."

Does this mean that for add-reference to work, the dll has to be in
managed
code or COM dll in unmanaged code?

Yes, it does. You can use a non-managed, non-COM DLL by means of
Platform Invoke (using the [DllImport] attribute), but it can't be added as
a Reference.
How to tell if a DLL is in managed or unmanaged code?

You can try to open it with ILDASM.EXE. It will give you an error
message if it is not managed code, otherwise it will show you the contents
of the DLL.
 
Back
Top