如何从Visual C ++ 6.0 exe调试C#DLL [英] How to debug a C# dll from a Visual C++ 6.0 exe

查看:124
本文介绍了如何从Visual C ++ 6.0 exe调试C#DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:

Visual C ++ 6.0(Exe) - 使用ATL COM(使用Visual Studio 6.0开发 - msdev);它调用C#dll(使用Visual Studio 2010开发 - .NET Framework 2.0)。



我想从VC ++ exe调试C#dll。这两个文件都是在调试模式下构建的。在C#dll(Visual Studio 2010)中,我尝试了以下内容:

1.设置项目属性 - >调试 - >启用非托管代码调试。

2.在C#dll中,我在构造函数中保留断点,并从VC ++ exe调用该方法;调试 - >附加到流程 - > msdev(VC ++ exe)。在这样做时,我收到消息断点当前不会被命中。此文档没有加载任何符号。



FYI:我能够调试使用Debug - >来自VB6.exe(非托管代码)的相同C#dll(托管代码)附加到流程。





先谢谢。

Environment:
Visual C++ 6.0 (Exe) - using ATL COM (developed using Visual studio 6.0 - msdev); it calls a C# dll (developed using Visual studio 2010 - .NET Framework 2.0).

I would like to debug a C# dll from a VC++ exe. Both the files were built in Debug mode. In the C# dll (Visual Studio 2010), I have tried the following:
1. Setting the Project Properties -> Debug -> Enable unmanaged code debugging.
2. In the C# dll I have kept breakpoint in the constructor and the method being called from the VC++ exe; Debug -> Attach To Process -> msdev (VC++ exe). On doing so, I get the message "The breakpoint will not currently be hit. No symbols have been loaded for this document."

FYI: I am able to Debug the same C# dll (Managed code) from a VB6.exe (unmanaged code) using Debug -> Attach to Process.


Thanks in Advance.

推荐答案

As可能性(我还没有尝试过)如果你只是想调试C#本身然后在某个早期点添加以下内容(ctor甚至添加静态ctor。)



System.Diagnostics.Assert.Debug(false);



然后让IDE加载C#dll代码。当上面的语句被击中时,你应该得到关于某些东西的讨论(我不再读它了)但是在几个按钮中有一个重试按钮。点击它然后它将询问使用哪个IDE - 用你加载的C#代码选择一个。



一旦你这样做,你可以添加适当的断点,它们会命中每次只要你不重启原来的应用程序。只要你有适当的断点,原始线就可以在第一次击中后被忽略(另一个按钮)。
As possibility (I haven't tried it) if you just want to debug the C# itself then add the following at some early point (ctor or even add a static ctor.)

System.Diagnostics.Assert.Debug(false);

Then have the IDE up with the C# dll code loaded. When the above statement is hit you should get dialog babbling about something (I don't read it anymore) but among several buttons there is a Retry button. Hit it then it will ask which IDE to use - pick the one with your loaded C# code.

Once you do that you can add appropriate break points and they will hit every time as long as you don't restart the original app. The original line can be Ignored (another button) after the first hit as long as you have appropriate break points.


使用System.Diagnostics.Debugger.Break();
$只要不是COM dll,b $ b就可以工作
use System.Diagnostics.Debugger.Break();
will work as long as it is not a COM dll


这篇关于如何从Visual C ++ 6.0 exe调试C#DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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