I have following appDomainManager code
public class HostAppDomainManager : AppDomainManager
{
public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
{
this.InitializationFlags = AppDomainManagerInitializationOptions.RegisterWithHost;
}
}
and following unmanaged code for starting the runtime host
int _tmain(int argc, _TCHAR* argv[])
{
ICLRMetaHost *pMetaHost = NULL;
HRESULT hr;
ICLRRuntimeInfo *runtimeInfo = NULL;
__try
{
hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost, (LPVOID*)&pMetaHost);
hr = pMetaHost->GetRuntime(L"v4.0.30319",IID_ICLRRuntimeInfo,(LPVOID*)&runtimeInfo);
ICLRRuntimeHost *runtimeHost = NULL;
hr = runtimeInfo->GetInterface(CLSID_CLRRuntimeHost,IID_ICLRRuntimeHost, (LPVOID*)&runtimeHost);
ICLRControl* clrControl = NULL;
hr = runtimeHost->GetCLRControl(&clrControl);
hr = clrControl->SetAppDomainManagerType(L"ExceptionThrower.dll",L"ExceptionThrower.HostAppDomainManager");
hr = runtimeHost->Start();
}
__except(1)
{
wprintf(L"\n Error thrown %d",e);
}
return 0;
}
the call to runtimeHost->Start() fails with error code -2146233054, cansomeone point out what should i do to fix this ?
if anyone else running into this, the problem is that the dll implementing AppDomainManager shoudl be strongly named.
so change the code to