Q:
How do I load a .NET managed assembly from an ObjectARX application?
A:
To load a managed assembly from an arx application, you can use LoadManagedDll API exported from acdbmgd.dll.
The signature is Acad::ErrorStatus LoadManagedDll(const char* fname)
You must use GetProcAddress since we do not provide the import library for acmgd.dll:
typedef Acad::ErrorStatus (__stdcall* funcPtr)(const TCHAR* fname);
static void TestMyNetLoad(void)
{
ACHAR fileName[MAX_PATH];
if( RTNORM != acedGetString(true, _T("\nDLL full name: "), fileName) )
{
acutPrintf(_T("\nSomething wrong with the file name input!"));
return;
}
HMODULE hAcMgd = ::GetModuleHandle(_T("ACDBMGD.DLL"));
funcPtr pLoadMgd = (funcPtr)::GetProcAddress(hAcMgd, "LoadManagedDll");
if( pLoadMgd )
{
Acad::ErrorStatus es = (*pLoadMgd)(fileName);
if( es != Acad::eOk )
{
acutPrintf(_T("\nError in loading the .NET DLL!"));
return;
}
}
else
{
acutPrintf(_T("\nError getting function pointer to LoadManagedDll()!"));
return;
}
}
