C# 无法在新AppDomain内创建UserControl
当我将程序集(xxx.dll)加载到新的AppDomain并尝试在其中创建UserControl时,会发生异常:C# 无法在新AppDomain内创建UserControl,c#,wpf,appdomain,C#,Wpf,Appdomain,当我将程序集(xxx.dll)加载到新的AppDomain并尝试在其中创建UserControl时,会发生异常: Could not load file or assembly 'xxx.resources' or one of its dependencies. 当我将程序集加载到主AppDomain时,它工作正常。 为什么会发生异常 public void InitializeComponent() { if (_contentLoaded) { return; } _cont
Could not load file or assembly 'xxx.resources' or one of its dependencies.
当我将程序集加载到主AppDomain时,它工作正常。为什么会发生异常
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
//这里出现了异常
System.Uri resourceLocater = new System.Uri("/Company.AddInApp;component/controls/usercontrol.xaml", System.UriKind.Relative);
#line 1 "..\..\..\Controls\UserControl1.xaml" stem.Windows.Application.LoadComponent(this, resourceLocater);
#line default
#line hidden
}
我发现了错误:
var setup = new AppDomainSetup
{
ApplicationBase = rootAddInsPath,
........
};
var appDomain = AppDomain.CreateDomain(...)
//I don't must do this here!!!
appDomain.AssemblyResolve += (sender, args) =>
{
....
}
var managerType = typeof(AddInLoadManager);
var manager =(AddInLoadManager)appDomain.CreateInstanceAndUnwrap(managerType.Assembly.FullName, managerType.FullName);
“AppDomain.AssemblyResolve”事件的正确位置位于“AddInLoadManager”类中
谢谢你的帮助@YK1SOS伙计们。。。需要帮助…你应该用fusion log viewer调试它-fusion log没有告诉我什么,它只是显示搜索路径(AppDomain基本目录)中缺少哪些程序集。它还添加了locale(ex:en-en)目录以从中搜索。。。(((那么,
xxx.resources
assembly是否确实存在于它所搜索的任何路径中?如果不存在,那么它存在于什么路径中?“xxx.resources”assembly不存在。。。