WPF类加载错误?添加自定义类时崩溃

时间:2012-09-10 01:08:25

标签: wpf class runtime-error

弹出

An unhandled exception of type 'System.IO.IOException' occurred in
PresentationFramework.dll

Additional information: Cannot locate resource 'mainwindow.xaml'.

输出记录

'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'
...
'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'
The thread 'vshost.NotifyLoad' (0x6b0) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1fa8) has exited with code 0 (0x0).
'markless.vshost.exe' (Managed (v4.0.30319)): Loaded 'T:\#_\Programming\GitHub\markless\src\win2\markless\bin\Debug\markless.exe', Symbols loaded.
Step into: Stepping over method without symbols 'markless.App.App'
'markless.vshost.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'
A first chance exception of type 'System.IO.IOException' occurred in PresentationFramework.dll
An unhandled exception of type 'System.IO.IOException' occurred in PresentationFramework.dll
Additional information: Cannot locate resource 'mainwindow.xaml'.
The program '[6268] markless.vshost.exe: Program Trace' has exited with code 0 (0x0).
The program '[6268] markless.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).

每次我尝试将C#类添加到项目时都会发生这种情况。它是WPF,当我开始一个新项目时,它只能用窗口运行。在我尝试向应用程序添加实际功能的那一刻,它就像这样吹嘘我。 (哦,它构建,它构建得足够公平 - 这是一个运行时错误。)即使我删除了类,应用程序仍然无法正常运行。 Wat do?

感谢任何帮助。

  

前进的方法有很多种,但只有一种方法可以保持不变。 - FDR

编辑: 如果您想查看回购,请right here

1 个答案:

答案 0 :(得分:5)

  

其他信息:找不到资源'mainwindow.xaml'。

您的App.xaml

<Application x:Class="markless.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">

问题不是添加任何类,而是删除/重命名MainWindow,这里仍然引用。