【发布时间】:2014-05-12 17:53:01
【问题描述】:
我有一个 C# WPF 应用程序,并且正在尝试找出一种方法来使用转储文件在 Visual Studio 2010 中查明崩溃位置。我正在使用 SysWow64\TaskMgr.exe 来获取我的崩溃转储500MB。
这是我的启动代码,它使用 Visual Basic 解决方法来确保我只运行一个实例。
using System;
using Microsoft.VisualBasic.ApplicationServices;
namespace UselessCrashDump
{
public class Startup
{
[STAThread]
public static void Main(string[] args)
{
SingleInstanceManager singleInstanceManager = new SingleInstanceManager();
singleInstanceManager.Run(args);
}
}
// Using VB bits to detect single instances and process accordingly:
// * OnStartup is fired when the first instance loads
// * OnStartupNextInstance is fired when the application is re-run again
public class SingleInstanceManager : WindowsFormsApplicationBase
{
App _app;
public SingleInstanceManager()
{
this.IsSingleInstance = true;
}
protected override bool OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
{
//first launch
_app = new App();
_app.InitializeComponent();
_app.Run();
return false;
}
protected override void OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)
{
//subsequent launches
base.OnStartupNextInstance(eventArgs);
_app.Activate();
}
}
}
现在我在我的应用程序中添加了一段代码,它会在我按下按钮后故意让它崩溃。代码如下所示:
private void _crash_Click(object sender, RoutedEventArgs e)
{
CrashMe(null);
}
private void CrashMe(string someString)
{
someString.Split(' ');
}
果然,在我运行exe并单击按钮后,程序崩溃了。然后我获取故障转储,打开它,这就是我看到的:
我期待代码在崩溃的特定位置中断。但是,故障转储指向程序的入口点。所有崩溃都会发生这种情况。我想查看崩溃的确切位置,以及它在调试会话期间发生的方式。
我做错了什么?转储文件本身似乎正在加载 PDB 文件,至少从输出来看:
'[MyApp].DMP' (Managed): Loaded 'C:\Program Files (x86)\[MyCompany]\[MyApp].exe', Symbols loaded.
它似乎没有加载本机符号,但我想既然它是一个托管应用程序,我不需要它们:
'[MyApp].DMP': Loaded 'C:\Program Files (x86)\[MyCompany]\[MyApp].exe', No native symbols in symbol file.
【问题讨论】:
标签: c# wpf crash-dumps