Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法在新AppDomain内创建UserControl_C#_Wpf_Appdomain - Fatal编程技术网

C# 无法在新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

当我将程序集(xxx.dll)加载到新的AppDomain并尝试在其中创建UserControl时,会发生异常:

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”类中


谢谢你的帮助@YK1

SOS伙计们。。。需要帮助…你应该用fusion log viewer调试它-fusion log没有告诉我什么,它只是显示搜索路径(AppDomain基本目录)中缺少哪些程序集。它还添加了locale(ex:en-en)目录以从中搜索。。。(((那么,
xxx.resources
assembly是否确实存在于它所搜索的任何路径中?如果不存在,那么它存在于什么路径中?“xxx.resources”assembly不存在。。。