C#应用程序中的非托管调用堆栈 [英] Unmanaged call stack in c# application

查看:90
本文介绍了C#应用程序中的非托管调用堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编写的非托管dll中遇到访问冲突错误,但是当我尝试在c#应用程序中对其进行调试时,它将仅在Visual Studio的调试窗口中获得调用堆栈的最后一帧.

I am getting an access violation error in an unmanaged dll I am writing, but when I try to debug It in a c# application it will only get the last frame of the call stack in Visual Studio's debug window.

我将debug-> exceptions-> System.AccessViolationException设置为在引发调试器时中断调试器.

I have debug->exceptions->System.AccessViolationException set to break the debugger when it is thrown.

myunmanaged.dll!ViolatingFunc() Line 100 + 0xc bytes
- - - -
[external code] //myunmanaged.dll!function that I want to see
- - - -
somecsharp.exe!com.somewhere.Form1.CallFuncThatCallsViolator();

我希望在非托管堆栈中走走,以查看将数据转至garbeldegook的地方. 这可能吗?

I was hoping to walk up the unmanaged stack to see where the data gets turned to garbeldegook. Is this possible?

已回答

启用非托管调试是第1步,但要使我一路启用Microsoft符号.

Enabling unmanaged debugging is step 1, but to get me all the way there I enabled microsoft symbols.

这使我的堆栈跟踪看起来更像这样:

that made my stack trace look more like this:

myunmanaged.dll!ViolatingFunc() 
- - - -
myunmanaged.dll!SomeFunc2() 
- - - -
myunmanaged.dll!SomeFunc()
- - - -
[managed to unmanaged code transition]
- - - -
somecsharp.exe!com.somewhere.Form1.CallFuncThatCallsViolator();

推荐答案

是的.您需要在混合模式"下调试应用程序.右键单击该项目,选择调试"选项卡,然后选中启用非托管代码调试".您将看到托管框架和本机框架.

Yes it is. You need to debug your application in 'Mixed-mode'. Right click on the project, select the 'Debug' tab and check 'Enable unmanaged code debugging'. You will see managed and native frames.

编辑:正如ChrisO所提到的,没有MS符号会使本地调试变得很奇怪.将以下内容添加到Windows符号的符号路径中:http://msdl.microsoft.com/download/symbols

Edit: As ChrisO mentions not having MS symbols can make native debugging weird. Add the following to your symbols path for Windows symbols: http://msdl.microsoft.com/download/symbols

这篇关于C#应用程序中的非托管调用堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆