C# 和 WPF - PresentationFramework.dll 中发生“System.Reflection.TargetInvocationException”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16922355/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C# and WPF - 'System.Reflection.TargetInvocationException' occurred in PresentationFramework.dll
提问by phil
I am working on a wpf application with visual studio 2012. The program had been starting up just fine until now. I had just finished adding a decent amount of code, and I hadn't started the program in a while. When I attempted to, I got a System.Reflection.TargetInvocationException. I tried to step into the code, but I got the message "PresentationFramework.pdb not loaded".
我正在使用visual studio 2012 开发一个wpf 应用程序。该程序直到现在才启动得很好。我刚刚添加了相当数量的代码,而且我已经有一段时间没有启动该程序了。当我尝试时,我得到了 System.Reflection.TargetInvocationException。我试图单步执行代码,但收到消息“PresentationFramework.pdb 未加载”。
I tried 'Start without debugging'. This time I got no exception, but it just didn't do anything. I have tried commenting out portions of my code to find the problem points, but I made no progress.
我试过“不调试就开始”。这次我没有例外,但它只是没有做任何事情。我曾尝试注释掉部分代码以找到问题点,但没有取得任何进展。
The code I had just added had nothing to do with wpf, if that has anything to with it.
我刚刚添加的代码与 wpf 无关,如果与它有关的话。
回答by nyconing
Make sure your xaml code is correct and clear all syntax at
确保您的 xaml 代码正确并清除所有语法
public MainWindow()
{
InitializeComponent();
}
回答by John Koffee
Try to start debugging from Window.Initializedevent
尝试从Window.Initialized事件开始调试
private void Window_Initialized(object sender, EventArgs e) {
int a; //put breakpoint here
}
XAML code:
XAML 代码:
<Window x:Class="ProjectName.MainWindow" ... Initialized="Window_Initialized">

