System.Xaml.dll 中的“MS.Internal.Xaml.Parser.GenericTypeNameParser.TypeNameParserException”

问题描述 投票:0回答:3

当我尝试运行我的项目时,我现在遇到了这个异常。我没有更改任何代码。

抛出异常:System.Xaml.dll中的“MS.Internal.Xaml.Parser.GenericTypeNameParser.TypeNameParserException”

其他信息:前缀“自定义”不映射到命名空间。

“自定义”是指App.xaml中的MAHapps Metro工具包:

<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:d1p1="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:Custom="http://metro.mahapps.com/winfx/xaml/controls" 
         xmlns:Custom1="http://metro.mahapps.com/winfx/xaml/shared" 

我不知道为什么这会突然改变。我把VS2015更新到最新版本了还是不行

更新: 我将 InitializeComponent() 调用放入 try catch 中以尝试获取异常对象,现在不会引发异常。

        try
        {
            InitializeComponent();
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.InnerException.Message);
        }

更新2: 它仍然抛出异常,但“catch (Exception ex)”由于某种原因忽略了 TypeNameParserException。

c# wpf xaml mahapps.metro
3个回答
0
投票

完全卸载并重新安装 VS 2015 解决了该问题。


0
投票

我的猜测是,异常是在 WPF 的 XAML 处理中的某个地方捕获的。这就是为什么你无法捕获异常的原因。您遇到的问题来自 Visual Studio 的设置。在这里您可以知道发生异常时该怎么做。 (从 VS 2015 开始,有一个特殊的窗口来控制它。调试 -> Windows -> 异常设置)如果该 CLR 异常中有标记,Visual Studio 将停止并向您显示异常,即使它在常规操作中不会显示。您可以尝试通过将所有异常标记为显示来恢复问题。


0
投票

我在 VS 2022 中的 WPF.NET 解决方案中遇到了这个问题。我最近关闭了“仅启用我的代码”以在

Release
配置中进行调试。当我切换回
Debug
配置时,我注意到这些错误。

我必须重新打开“仅启用我的代码”才能停止收到此错误。

© www.soinside.com 2019 - 2024. All rights reserved.