R
Rich
I am trying to use unmanaged DLLs within managed code. My approach is
to create a managed DLL with wrapper functions for my unmanaged
functions. The unmanaged functions come from an unmanaged DLL.
I can successfully build my managed DLL and use it from managed code.
However, at runtime the code cannot find the unmanaged DLL. I've tried
putting the unmanaged DLL in the same directory as the code is running
from, in C:\Windows\System32, and a few other places - no luck, I
always get an error indicating that the unmanaged DLL cannot be found.
Here is what I do in my managed DLL to access functions in the
unmanaged DLL:
using namespace System::Runtime::InteropServices;
[DllImport("ADT_API_L1", EntryPoint="ADT_L1_Initialize")]
extern "C" unsigned int ADT_L1_Initialize(unsigned int dev_num,
char *filename);
The unmanaged DLL is "ADT_API_L1.dll". In the code for the managed DLL
I also define a namespace and classes with member functions that call
unmanaged functions like "ADT_L1_Initialize" - I left this out to keep
this as uncluttered as possible.
application compiles without error, but when I run the program it
chokes and dies, giving an error that it cannot load the DLL
(System.DllNotFoundException).
I'm sure there is something simple and stupid that I am missing. Can
anybody here set me straight?
to create a managed DLL with wrapper functions for my unmanaged
functions. The unmanaged functions come from an unmanaged DLL.
I can successfully build my managed DLL and use it from managed code.
However, at runtime the code cannot find the unmanaged DLL. I've tried
putting the unmanaged DLL in the same directory as the code is running
from, in C:\Windows\System32, and a few other places - no luck, I
always get an error indicating that the unmanaged DLL cannot be found.
Here is what I do in my managed DLL to access functions in the
unmanaged DLL:
using namespace System::Runtime::InteropServices;
[DllImport("ADT_API_L1", EntryPoint="ADT_L1_Initialize")]
extern "C" unsigned int ADT_L1_Initialize(unsigned int dev_num,
char *filename);
The unmanaged DLL is "ADT_API_L1.dll". In the code for the managed DLL
I also define a namespace and classes with member functions that call
unmanaged functions like "ADT_L1_Initialize" - I left this out to keep
this as uncluttered as possible.
reference and I can see my namespace, classes, etc. The managedFrom my managed CLR application I include the managed DLL as a
application compiles without error, but when I run the program it
chokes and dies, giving an error that it cannot load the DLL
(System.DllNotFoundException).
I'm sure there is something simple and stupid that I am missing. Can
anybody here set me straight?