B
belion
Hi,
I am facing a strange problem ... a collegue of mine made two
projects. The first one is an unmanaged C++ dll , and the other is a
C# managed project that uses the previous dll. Both of them are
working on his machine, but not in mine. When I run the C# project, I
always get a DllNotFoundException, even it the path to the dll is well
set (I have checked it). I have also tried to copy the dll to C:
\WINDOWS\system32 , but the same problem arises.
Some lines of code.
The important part from the C++ dll
#define NAG_CALL __stdcall
#define NAG_DLL_EXPIMP __declspec(dllexport)
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C"
{
NAG_DLL_EXPIMP void NAG_CALL MallocImage(Image *img)
{
img->imageData =
(char *)malloc((size_t)(sizeof(char)*img->imageSize));
}
}
And in the C# project
[DllImport(@"C:\Projects\code\OpenCvBridge\TrialBridge\Debug
\TrialBridge.dll", EntryPoint = "MallocImage")]
public static extern void MallocImage(ref Image img);
.......
Image img = new Image();
img.imageSize = 600 * 800;
MallocImage(ref img);
.......
It always fails when it arrives to MallocImage(ref img)
By the way, I checked the dll with DependencyWalker, and it does not
have additional dependencies.
Thank you,
I am facing a strange problem ... a collegue of mine made two
projects. The first one is an unmanaged C++ dll , and the other is a
C# managed project that uses the previous dll. Both of them are
working on his machine, but not in mine. When I run the C# project, I
always get a DllNotFoundException, even it the path to the dll is well
set (I have checked it). I have also tried to copy the dll to C:
\WINDOWS\system32 , but the same problem arises.
Some lines of code.
The important part from the C++ dll
#define NAG_CALL __stdcall
#define NAG_DLL_EXPIMP __declspec(dllexport)
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C"
{
NAG_DLL_EXPIMP void NAG_CALL MallocImage(Image *img)
{
img->imageData =
(char *)malloc((size_t)(sizeof(char)*img->imageSize));
}
}
And in the C# project
[DllImport(@"C:\Projects\code\OpenCvBridge\TrialBridge\Debug
\TrialBridge.dll", EntryPoint = "MallocImage")]
public static extern void MallocImage(ref Image img);
.......
Image img = new Image();
img.imageSize = 600 * 800;
MallocImage(ref img);
.......
It always fails when it arrives to MallocImage(ref img)
By the way, I checked the dll with DependencyWalker, and it does not
have additional dependencies.
Thank you,