Hi, I'm trying to get a simple mixture between Managed C++ and plain C++ working. I'm using Visual Studio 2005 but keep hitting a problem. Here's my setup.
First, I have a simple DLL built from the code
#using "mscorlib.dll"
#include "windows.h"
__declspec(dllexport)
void sayHello()
{
OutputDebugStringA( "Hello from managed code!" );
}
I compile this on the commandline to a DLL using
cl /CLR /LD dllcode.cpp
Next, I have a simple program consisting of nothing more than
#include <windows.h>
int main()
{
HINSTANCE lib = LoadLibrary( "dllcode.dll" );
if ( !lib ) {
return 1;
}
return 0;
}
I build an application out of this using
cl loader.cpp
So I end up with dllcode.dll
and loader.exe
in the same directory. When trying to run loader.exe
, I always get return code '1'. Looking up the error code yielded by GetLastError()
shows that loading dllcode.dll
failed due to The specified module could not be found.
Does anybody know why this could be? Does it have something to do with manifests which need to be embedded into dllcode.dll
or so? I ran the depends program on dllcode.dll but it didn't yield any problems as far as I could tell.