From quick look,
- I am not expert, but I think you should use AssemblyResolver instead load assembly directly.
System::Reflection::Assembly ^ WPF::WApp::MyResolveEventHandler(System::Object ^ sender, System::ResolveEventArgs ^ args)
{
bool ok = false;
try {
result = Assembly::LoadFrom(assemblyPath);
ok = true;
}
catch (Exception ^e)
{
LoggerCPPInt::mf_writeLog("C++/CLI", "MyResolveEventHandler()", "LOAD FAILED", msc::convert_to_string(e->ToString()));
}
if (ok == true)
{
return result;
}
else
{
return args->RequestingAssembly;
}
}
// ==========================================================
// Somewhere where you initialize WPF
AppDomain ^cd = AppDomain::CurrentDomain;
cd->AssemblyResolve += gcnew ResolveEventHandler(WPF::WApp::MyResolveEventHandler);
This is worked for me if I used UserControl only.
- your function for get HWND need to be corrected to this
MeterWpfWrapper::MeterWpfWrapper(void ** hWnd) { .. }
// then call
m_UI = std::make_shared<MeterWpfWrapper>(&m_parentWindow);
I don’t know how you then attach the HWND in to HostWindow but this is how I did it
if (h == nullptr)
{
wpfi->mf_Window_GetPointer(&h);
SetParent((HWND)h, (HWND)systemWindow);
}