簡體   English   中英

在 PresentationFramework.dll 中發生 System.Windows.Markup.XamlParseException'?

[英]System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll?

我在 C# 上使用 WPF 作為代碼波紋管

<Window       
    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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
    xmlns:utility="clr-namespace:DVRClientInterface.Utility"
    xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"     
    xmlns:wpftoolkit="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"   
    xmlns:customControl="clr-namespace:DVRClientInterface.CustomControls"    
    x:Class="DVRClientInterface.MainWindow"
    WindowStyle="None" ResizeMode="CanMinimize"
    AllowsTransparency="True"
    WindowState = "Maximized"
    WindowStartupLocation="CenterScreen"    
    StateChanged="Window_StateChanged" 
    KeyUp="Window_KeyUp" 
    KeyDown="Window_KeyDown"    
    Closing="Window_Closing" Loaded="Window_Loaded"
     >
    <!-- WindowState = "Maximized" -->
    <Window.Background>
        <ImageBrush ImageSource="Resources\main_background.png"/>
    </Window.Background>

    <Grid x:Name="MainWindowGrid">
     //My GUI Code here

    </Grid>
</Window>

當我運行應用程序時,它會拋出以下異常

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'The invocation of the constructor on type 'DVRClientInterface.MainWindow' that matches the specified binding constraints threw an exception.' Line number '9' and line position '5'.

If there is a handler for this exception, the program may be safely continued.

第 9 行是xmlns:customControl="clr-namespace:DVRClientInterface.CustomControls"

但我不知道為什么,在此之前 XAML 仍然可以正常工作。 我只是在 C++ 項目中編輯代碼,然后它總是拋出該異常。

許多主題說這是由項目配置引起的,但我不知道我的項目配置中的哪個位置引發了此異常。

有人可以建議我如何解決它?

更新:輸出調試如下

'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\MysticClient.exe', No native symbols in symbol file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\mscoree.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\msvcr110_clr0400.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\51e2934144ba15628ba5a31be2dae7dc\mscorlib.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\MysticClient.exe', Symbols loaded.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System\e40da7a49f8c3f0108e7c835b342f382\System.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\WindowsBase\cd235caf797fb017f140016be88f33b7\WindowsBase.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\cryptsp.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\rsaenh.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\PresentationCore\b52bc540630c3aa5de542c382af35c20\PresentationCore.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\Presentatio5ae0f00f#\97e6b67983d07a066b68b3ae8be2f53d\PresentationFramework.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xaml\cc4d9093563dadee370788bbc3ecf4fb\System.Xaml.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\DWrite.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\wpfgfx_v0400.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationNative_v0400.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrjit.dll', Cannot find or open the PDB file.
Step into: Stepping over non-user code 'DVRClientInterface.App.App'
'MysticClient.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\nlssorting.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Configuration\28586400bcaf94c13a9fd0dff4a1e090\System.Configuration.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xml\9ba07396ae369d010c5c3927a82ef426\System.Xml.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file.
Step into: Stepping over non-user code 'DVRClientInterface.App.InitializeComponent'
'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\CPPWrapper.dll', Symbols loaded.
'MysticClient.exe': Unloaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\CPPWrapper.dll'
'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\CPPWrapper.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\RpcRtRemote.dll', Cannot find or open the PDB file.
'MysticClient.exe': Unloaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\CPPWrapper.dll'
'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\CPPWrapper.dll', Symbols loaded.
'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\Common.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\IPHLPAPI.DLL', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\nsi.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\winnsi.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\msvcr110d.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\msvcp110d.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\ws2_32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\DVRClientCore.dll', Symbols loaded.
'MysticClient.exe': Loaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\ClientCommunication.dll', Symbols loaded.
First-chance exception at 0x7757b499 in MysticClient.exe: 0xC0000005: Access violation writing location 0x00000014.
'MysticClient.exe': Unloaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\CPPWrapper.dll'
'MysticClient.exe': Unloaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\DVRClientCore.dll'
'MysticClient.exe': Unloaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\ClientCommunication.dll'
'MysticClient.exe': Unloaded 'E:\TIN HOC\Learning\Chuong Tring Dao Tao\Working\Main_Code\SecurityLabCode\DVRClient\Bin\x86\Debug\Common.dll'
'MysticClient.exe': Unloaded 'C:\Windows\SysWOW64\ws2_32.dll'
'MysticClient.exe': Unloaded 'C:\Windows\SysWOW64\msvcp110d.dll'
'MysticClient.exe': Unloaded 'C:\Windows\SysWOW64\msvcr110d.dll'
'MysticClient.exe': Unloaded 'C:\Windows\SysWOW64\IPHLPAPI.DLL'
'MysticClient.exe': Unloaded 'C:\Windows\SysWOW64\winnsi.dll'
'MysticClient.exe': Unloaded 'C:\Windows\SysWOW64\nsi.dll'
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: EEFileLoadException at memory location 0x00a7ab9c.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: Exception at memory location 0x00a7cae4.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74e8b9bc in MysticClient.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
'MysticClient.exe': Loaded 'C:\Windows\SysWOW64\version.dll', Cannot find or open the PDB file.
An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll
Additional information: 'The invocation of the constructor on type 'DVRClientInterface.MainWindow' that matches the specified binding constraints threw an exception.' Line number '9' and line position '5'.
The program '[5664] MysticClient.exe: Native' has exited with code -1 (0xffffffff).
The program '[5664] MysticClient.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).

非常感謝!

電訊報

這不是 XAML 的問題。 錯誤消息是說它嘗試創建DVRClientInterface.MainWindow的實例,並且您的構造函數引發了異常。

您需要查看“內部異常”屬性以確定根本原因。 它可以是任何字面上的東西,但應該提供方向。

Visual Studio 中顯示的內部異常示例

例如,如果您在窗口的構造函數中連接到數據庫,並且由於某種原因該數據庫不可用,則內部異常可能是TimeoutExceptionSqlException或數據庫代碼拋出的任何其他異常。

如果您在靜態構造函數中拋出異常,則可以從MainWindow引用的任何類生成異常。 如果任何MainWindow字段正在調用可能拋出的方法,類初始值設定項也會運行。

問題解決了! 我正在使用 Ctrl + Alt + E 打開異常窗口,並且我選中了所有 throw 復選框。 因此調試器可以准確地停在錯誤代碼處。

我花了很長時間才解決這個問題,所以為了搜索者的利益:

我有一個奇怪的問題,即應用程序在調試中工作,但一旦發布就給出XamlParseException

修復了 Katjoek 詳細說明的 x86/x64 問題后,問題仍然存在。

問題是 CEF 教程說要從 NuGet 降低System.Windows.Interactivity (甚至認為它在 .NET 中引用的擴展部分)並從 NuGet 降低將specific version設置為true

部署后,不同版本的System.Windows.Interactivity被不同的應用程序打包。

拒絕使用不同版本的 dll 導致整個應用程序因XamlParseException崩潰。

我在使用“所有 cpu”目標構建我的應用程序時遇到了這個問題,同時它引用了 3rd 方 x64-only(托管)dll。

更新:這不是解決方案,但它是可能導致問題中出現的異常的問題的解決方法。

我已經解決了從發布配置更改為調試配置的問題。

當我遇到這個問題時,我實際上只是忘記在代碼的 XAML 中填寫參數值。

但出於某種原因,異常會將我發送到 WPF 程序的 CS 而不是 XAML。 不知道為什么。

在我的情況下,當我分配給兩個動態創建的控件(組合框)和來自其他類的相同創建的控件時,就會出現此錯誤。

//dynamic created controls
ComboBox combobox1 = ManagerControls.myCombobox1;
...some events

ComboBox combobox2 = ManagerControl.myComboBox2;
...some events

.

//method in constructor
public static void InitializeDynamicControls()
{
     ComboBox cb = new ComboBox();
     cb.Background = new SolidColorBrush(Colors.Blue);
     ...
     cb.Width = 100;
     cb.Text = "Select window";
        
     ManagerControls.myCombobox1 = cb;
     ManagerControls.myComboBox2 = cb; // <-- error here
}

解決方案:創建另一個ComboBox cb2並將其分配給ManagerControls.myComboBox2

我希望我幫助了某人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM