简体   繁体   English

从 AppDomain 创建实例时程序集未解析

[英]assemblies not resolving while creating instance from AppDomain

var processAssembly  = Assembly.LoadFile(baseLocationCCDebugFolder+"\\CC.dll");
var processType = processAssembly.GetType("CC.Executor.CCProcess",true,true);

AppDomainSetup appDSetup = new AppDomainSetup()
{
  ApplicationBase = baseLocationCCDebugFolder,
  //PrivateBinPath = processAssembly.CodeBase
};

StrongName fullTrustAssembly = processAssembly.Evidence.GetHostEvidence<StrongName>();

AppDomain executionDomain = AppDomain.CreateDomain("ExecutionDomain",null,appDSetup,internetPS,fullTrustAssembly);
CCProcess process =(CCProcess)executionDomain.CreateInstanceAndUnwrap(processAssembly.ManifestModule.FullyQualifiedName, processType.FullName);

im encountering an error on the last line of this code which goes like this.我在此代码的最后一行遇到错误,如下所示。

Could not load file or assembly 'D:\\work\\compilerCom\\CompileCom_Build_4_newArchitecture\\CompilerCom\\CC\\bin\\Debug\\CC.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)<br/>

im still figuring my way in app domain.我仍在思考我在应用程序领域的方式。
what am i doing wrong?我究竟做错了什么?

EDIT:- the value of baseLocationCCDebugFolder variable is D:\\work\\compilerCom\\CompileCom_Build_4_newArchitecture\\CompilerCom\\CC\\bin\\Debug编辑:- baseLocationCCDebugFolder变量的值为D:\\work\\compilerCom\\CompileCom_Build_4_newArchitecture\\CompilerCom\\CC\\bin\\Debug

My guess is that it is not the Assembly not being found but one of the referenced assemblies not loading correctly.我的猜测是,不是找不到程序集,而是引用的程序集之一未正确加载。 You may need to handle the resolve assembly event in the parent appdomain.您可能需要处理父应用程序域中的 resolve assembly 事件。 There is a good post here describing it.这里有一篇很好的文章描述了它。

http://social.msdn.microsoft.com/forums/en-US/clr/thread/0a18ed66-6995-4e7c-baab-61c1e528fb82/ http://social.msdn.microsoft.com/forums/en-US/clr/thread/0a18ed66-6995-4e7c-baab-61c1e528fb82/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM