自定义AppDomainManager无法启动runtimeHost
我有以下 appDomainManager 代码
public class HostAppDomainManager : AppDomainManager
{
public override void InitializeNewDomain(AppDomainSetup appDomainInfo)
{
this.InitializationFlags = AppDomainManagerInitializationOptions.RegisterWithHost;
}
}
和以下用于启动运行时主机的非托管代码
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;
}
,对 runtimeHost->Start() 的调用失败,错误代码为 -2146233054,有人可以指出我应该做什么来解决这个问题吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果其他人遇到这个问题,问题是实现 AppDomainManager 的 dll 应该被强命名。
所以将代码更改为
if anyone else running into this, the problem is that the dll implementing AppDomainManager shoudl be strongly named.
so change the code to