Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

c# - System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll?

I'm using WPF on C# as code bellow

<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="Resourcesmain_background.png"/>
    </Window.Background>

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

    </Grid>
</Window>

When I run the app, it will throw following exception

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.

Line 9 is xmlns:customControl="clr-namespace:DVRClientInterface.CustomControls".

But I don't know why, before that the XAML still work fine. I just edit the code in the C++ project, and after that it always throw that exception.

Many topics said that it was caused by the projects config, but I don't know where in my projects config raise this exception.

Someone can suggest me how to fix it?

UPDATE: The output debug as below

'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugMysticClient.exe', No native symbols in symbol file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64
tdll.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64mscoree.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64kernel32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64KernelBase.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64advapi32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64msvcrt.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64sechost.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64
pcrt4.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64sspicli.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64cryptbase.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319mscoreei.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64shlwapi.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64gdi32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64user32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64lpk.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64usp10.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64imm32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64msctf.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319clr.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64msvcr110_clr0400.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32mscorlib51e2934144ba15628ba5a31be2dae7dcmscorlib.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_32mscorlibv4.0_4.0.0.0__b77a5c561934e089mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64ole32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64uxtheme.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugMysticClient.exe', Symbols loaded.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32Systeme40da7a49f8c3f0108e7c835b342f382System.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32WindowsBasecd235caf797fb017f140016be88f33b7WindowsBase.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64cryptsp.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64
saenh.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32PresentationCore52bc540630c3aa5de542c382af35c20PresentationCore.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32Presentatio5ae0f00f#97e6b67983d07a066b68b3ae8be2f53dPresentationFramework.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILPresentationFrameworkv4.0_4.0.0.0__31bf3856ad364e35PresentationFramework.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILWindowsBasev4.0_4.0.0.0__31bf3856ad364e35WindowsBase.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystemv4.0_4.0.0.0__b77a5c561934e089System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_32PresentationCorev4.0_4.0.0.0__31bf3856ad364e35PresentationCore.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32System.Xamlcc4d9093563dadee370788bbc3ecf4fbSystem.Xaml.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Xamlv4.0_4.0.0.0__b77a5c561934e089System.Xaml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64DWrite.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319WPFwpfgfx_v0400.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64oleaut32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319WPFPresentationNative_v0400.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319clrjit.dll', Cannot find or open the PDB file.
Step into: Stepping over non-user code 'DVRClientInterface.App.App'
'MysticClient.exe': Loaded 'C:WindowsMicrosoft.NETFrameworkv4.0.30319
lssorting.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32System.Configuration28586400bcaf94c13a9fd0dff4a1e090System.Configuration.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Configurationv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:WindowsassemblyNativeImages_v4.0.30319_32System.Xml9ba07396ae369d010c5c3927a82ef426System.Xml.ni.dll', Cannot find or open the PDB file.
'MysticClient.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Xmlv4.0_4.0.0.0__b77a5c561934e089System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64dwmapi.dll', Cannot find or open the PDB file.
Step into: Stepping over non-user code 'DVRClientInterface.App.InitializeComponent'
'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCPPWrapper.dll', Symbols loaded.
'MysticClient.exe': Unloaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCPPWrapper.dll'
'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCPPWrapper.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64RpcRtRemote.dll', Cannot find or open the PDB file.
'MysticClient.exe': Unloaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCPPWrapper.dll'
'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCPPWrapper.dll', Symbols loaded.
'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCommon.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64IPHLPAPI.DLL', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64
si.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64winnsi.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64msvcr110d.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64msvcp110d.dll', Symbols loaded.
'MysticClient.exe': Loaded 'C:WindowsSysWOW64ws2_32.dll', Cannot find or open the PDB file.
'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugDVRClientCore.dll', Symbols loaded.
'MysticClient.exe': Loaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugClientCommunication.dll', Symbols loaded.
First-chance exception at 0x7757b499 in MysticClient.exe: 0xC0000005: Access violation writing location 0x00000014.
'MysticClient.exe': Unloaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCPPWrapper.dll'
'MysticClient.exe': Unloaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugDVRClientCore.dll'
'MysticClient.exe': Unloaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugClientCommunication.dll'
'MysticClient.exe': Unloaded 'E:TIN HOCLearningChuong Tring Dao TaoWorkingMain_CodeSecurityLabCodeDVRClientBinx86DebugCommon.dll'
'MysticClient.exe': Unloaded 'C:WindowsSysWOW64ws2_32.dll'
'MysticClient.exe': Unloaded 'C:WindowsSysWOW64msvcp110d.dll'
'MysticClient.exe': Unloaded 'C:WindowsSysWOW64msvcr110d.dll'
'MysticClient.exe': Unloaded 'C:Windows

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This is not a problem with XAML. The error message is saying that it tried to create an instance of DVRClientInterface.MainWindow and your constructor threw an exception.

You will need to look at the "Inner Exception" property to determine the underlying cause. It could be quite literally anything, but should provide direction.

example of an inner exception shown in Visual Studio

An example would be that if you are connecting to a database in the constructor for your window, and for some reason that database is unavailable, the inner exception may be a TimeoutException or a SqlException or any other exception thrown by your database code.

If you are throwing exceptions in static constructors, the exception could be generated from any class referenced by the MainWindow. Class initializers are also run, if any MainWindow fields are calling a method which may throw.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...