簡體   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);

我在此代碼的最后一行遇到錯誤,如下所示。

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/>

我仍在思考我在應用程序領域的方式。
我究竟做錯了什么?

編輯:- baseLocationCCDebugFolder變量的值為D:\\work\\compilerCom\\CompileCom_Build_4_newArchitecture\\CompilerCom\\CC\\bin\\Debug

我的猜測是,不是找不到程序集,而是引用的程序集之一未正確加載。 您可能需要處理父應用程序域中的 resolve assembly 事件。 這里有一篇很好的文章描述了它。

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