gpt4 book ai didi

c# - LoadFromContext 发生

转载 作者:IT王子 更新时间:2023-10-29 04:17:59 26 4
gpt4 key购买 nike

我有一个非常简单的 C# 问题,它从库中加载 Windows WPF 窗口。这是代码:

public partial class App : Application
{
public App()
{
MainWindow mainWindow = new MainWindow();
mainWindow.Show();
}
}

但是当我运行它时,它在 mainWindow.Show(); 行中断并出现以下错误:

Managed Debugging Assistant 'LoadFromContext' has detected a problem in 'C:\Users.....\bin\Debug\Test.vshost.exe'.

Additional information: The assembly named 'WpfXamlDiagnosticsTap' was loaded from 'file:///C:/PROGRAM FILES (X86)/MICROSOFT VISUAL STUDIO 14.0/COMMON7/IDE/COMMONEXTENSIONS/MICROSOFT/CLIENTDIAGNOSTICS/XAMLDIAGNOSTICS/x64/WpfXamlDiagnosticsTap.dll' using the LoadFrom context.

The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies.

MainWindow 类只是从 System.Windows.Window; 扩展而来我不确定这意味着什么以及如何解决。刚刚升级到 Visual Studio 2015。

enter image description here

enter image description here

如果我忽略异常并继续,当我关闭最后一个窗口时会得到这个:

enter image description here

最佳答案

从 Visual Studio 2013 切换到 2015 后,我遇到了同样的问题。一些旧项目(WPF、.NET 4.5、MVVM Light)会产生此错误 - 其他则不会。在 Visual Studio 中,我可以跳过异常,但新创建的版本在加载时停止并尝试打开 JIT 调试器。

到目前为止,唯一的解决方案似乎是回滚到 Visual Studio 2013。

** 更新 **

最后我通过取消选中以下选项在 VS 2015 中解决了这个问题:

工具 –> 选项 –> 调试 –> 常规 –> 为 XAML 启用 UI 调试工具

关于c# - LoadFromContext 发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31362077/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com