Assembly^ CurrentDomain_AssemblyResolve(Object ^ sender, ResolveEventArgs ^ args)
{
array<System::Reflection::Assembly ^> ^ asms = AppDomain::CurrentDomain->GetAssemblies();
for (int i = 0; i < asms->Length; ++i)
{
if (asms[i]->FullName == args->Name)
return asms[i];
}
String ^ folderPath = Path::GetDirectoryName(Assembly::GetExecutingAssembly()->Location);
String ^ assemblyPath = Path::Combine(folderPath, (gcnew AssemblyName(args->Name))->Name + ".dll");
if (!File::Exists(assemblyPath))
return nullptr;
Assembly ^ assembly = Assembly::LoadFrom(assemblyPath);
return assembly;
}
virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
// Save critical data pointers before running the constructors (see afxdllx.h for details)
AFX_MODULE_STATE* pModuleState = AfxGetModuleState();
pModuleState->m_pClassInit = pModuleState->m_classList;
pModuleState->m_pFactoryInit = pModuleState->m_factoryList;
pModuleState->m_classList.m_pHead = NULL;
pModuleState->m_factoryList.m_pHead = NULL;
DanfossCADDLL.AttachInstance (_hdllInstance) ;
InitAcUiDLL () ;
// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;
AppDomain ^ currentDomain = AppDomain::CurrentDomain;
currentDomain->AssemblyResolve += gcnew ResolveEventHandler(CurrentDomain_AssemblyResolve);
_session = new CSession();
return (retCode) ;
}