简体   繁体   English

调试非托管应用程序并同时管理C#dll

[英]Debugging unmanaged application and managed C# dll at the same time

My setup: 我的设置:
Application.exe (Visual Studio 6.0 C++) Application.exe (Visual Studio 6.0 C ++)
Component.dll (Visual Studio 2010 C#) Component.dll (Visual Studio 2010 C#)
Application.exe uses Component.dll Application.exe使用Component.dll

I want to be able to debug my Visual Studio 6.0 C++ application and the Visual Studio 2010 C# component that it uses at the same time but I'm not sure if this is possible or not. 我希望能够同时调试我的Visual Studio 6.0 C ++应用程序和它使用的Visual Studio 2010 C#组件,但我不确定这是否可行。

I tried to launch the application from Visual Studio 6.0 and attach to that process ( Application.exe ) in my Visual Studio 2010 component solution but when I go to attach to the process ( Application.exe ) it is greyed out. 我尝试从Visual Studio 6.0启动应用程序并附加到我的Visual Studio 2010组件解决方案中的该进程( Application.exe ),但是当我转到附加到进程( Application.exe )时,它显示为灰色。 I tried switching the Attach To: to Native but this does not allow me to attach to this process. 我尝试将Attach To:切换为Native但这不允许我附加到此进程。 My Application.exe is still greyed out in the window. 我的Application.exe仍然在窗口中显示为灰色。

Is it possible to do this and if so how? 有可能这样做,如果是这样的话怎么样?

There can be only one debugger attached to a process, that's why the selection is grayed out. 一个进程只能附加一个调试器,这就是选择灰显的原因。 You have little use for the VS6 debugger, it doesn't know anything about managed code. 你几乎没有使用VS6调试器,它对托管代码一无所知。 You'll have to debug this from VS2010. 你必须从VS2010调试它。 Right-click your C# project, Properties, Debug. 右键单击C#项目,Properties,Debug。 Select "Start external program" and select your C++ .exe. 选择“启动外部程序”并选择您的C ++ .exe。 Tick the "Enable unmanaged code debugging option". 勾选“启用非托管代码调试选项”。

Set a breakpoint in your C# code and press F5 to start the .exe. 在C#代码中设置断点,然后按F5启动.exe。 The breakpoint indicator will turn solid as soon as the C++ code loads you DLL. 一旦C ++代码加载DLL,断点指示器就会变为稳定。 Debugging the C++ code might be possible too although you're working with a .pdb from the previous century. 尽管您使用的是上个世纪的.pdb,但也可能调试C ++代码。 You cannot single-step from the managed code into the C++ code, you have to set a breakpoint. 您不能单步从托管代码到C ++代码,您必须设置断点。

You cannot attach two different debuggers to the same process. 您不能将两个不同的调试器附加到同一进程。

Instead, you can attach it only to VS2010, but attach it as both managed and native. 相反,您只能将它附加到VS2010,但将其作为托管和本机附加。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM