problem adding reference

  • Thread starter Thread starter shashank.aka.invi
  • Start date Start date
S

shashank.aka.invi

Hi someone plz help me. I have made a dll in VC++ .NET using following
specifications

extern "C"
{
__declspec(dllexport) void Probe_Interfaces_Local()
{
//some code
}
}

i compiled it successfully and add the dll formed to another C# project
directory. The c# code looks like this...

using System;
using System.Runtime.InteropServices;

namespace read
{
class Capture
{
[DllImport("mod2.dll")]
public static extern void Probe_Interfaces_Local();
//some code
}
}
The C# project compiles successfully but when i run it it breaks with
dll exception and says unable to load dll(mod2.dll)
 
I am not very familiar with C# syntax, but have you investigated the
error code ? Also, is it possible that some dependent DLLs of mod2.dll
are not present and the loadlib of the mod2.dll is failing.
just my 2 cents worth..
 
Hi someone plz help me. I have made a dll in VC++ .NET using following
specifications

extern "C"
{
__declspec(dllexport) void Probe_Interfaces_Local()
{
//some code
}
}

i compiled it successfully and add the dll formed to another C# project
directory. The c# code looks like this...

using System;
using System.Runtime.InteropServices;

namespace read
{
class Capture
{
[DllImport("mod2.dll")]
public static extern void Probe_Interfaces_Local();
//some code
}
}
The C# project compiles successfully but when i run it it breaks with
dll exception and says unable to load dll(mod2.dll)

You must have the DLL in the path of the caller, that is the same directory
or in a directory which is in the path environment.
DllImport uses LoadLibrary to load the DLL, so the same search rules apply
here.

Willy.
 
Willy Denoyette said:
You must have the DLL in the path of the caller, that is the same
directory or in a directory which is in the path environment.
DllImport uses LoadLibrary to load the DLL, so the same search rules apply
here.
And in case the C++ DLL is compiled with /MD(d) and Visual C++
2005 you also need an embedded manifest to bind to the correct CRT
DLL. See the /MANIFESTDEPENDENCY linker switch.

Depends.exe, NT LDR (gflags.exe, "Show Loader Snaps" or _ShowSnaps
variable) are your friends.

-hg
 
Back
Top