在VS2010中调试C#COM程序集 [英] Debugging C# COM assembly in VS2010

查看:64
本文介绍了在VS2010中调试C#COM程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个C#程序集,它将通过COM从旧的vb6(即本机win32,而不是.net)应用程序调用。



我已经在W7 x64中安装了VS2010 Premium,我的目标只是使用Visual Studio来调试C#代码......其他提示:C#程序集是在x86模式(.NET4)中编译的,然后dll是在COM +下注册; ...过了一会儿我尝试在任何CPU模式下编译,没有任何结果...



总结,之后:

1)运行win32应用程序

2)在Foo方法上设置断点,

3)在win32进程上附加调试器.... br $> b $ b

***没什么.... ***

一切顺利但是那里无法激活VS中的调试器



有什么建议吗?



谢谢提前。



Flavio

解决方案

你可以做你想做的事,它有效。可能你没有显示一些细节,你搞砸了这种调试方法。



但它可以简单得多。 1)使用Visual Studio在程序集中加载解决方案。 2)在装配项目中选择时,使装配项目成为启动项目(在解决方案资源管理器的上下文菜单中设置启动项目.3)显示该项目的属性窗口,调试选项卡。 4)编辑命令行参数字段,输入应用程序的启动命令(VB6或您使用的任何东西,使用您的程序集启动应用程序的命令)。 5)在程序集的源代码中,在要调试的代码中的某处设置断点。 6)单击F5或Debug - >开始调试。



享受调试。



-SA

从菜单Debug->Attach to ..选项,请指出正确的进程即dllhost.exe COM Surrogate。而不是win32客户....


I'm developing a C# assembly which is to be called via COM from an old vb6 (ie, "native" win32, not .net) application.

I've installed VS2010 Premium in a W7 x64 and simply my goal is to use Visual Studio to debug the C# code...Other hint: the C# assembly is compiled in "x86 mode" (.NET4) and then the dll is registered under COM+; ...after a while i've try to compile in "Any CPU" mode, without any result...

in summary, after:
1) running the win32 app
2) setting the breakpoint on "Foo" method,
3) attaching the debugger on win32 process....

*** nothing ....***
Simply all works well but there is no way to activate the debugger in VS

Any suggestions?

Thanks in advance.

Flavio

解决方案

You can do what you tried to do, it works. Probably, you did not show some detail where you screw up this method of debugging.

But it can be much simpler. 1) Load the solution with your assembly with Visual Studio. 2) Make your assembly project a startup project ("Set a StartUp Project" in context menu of the Solution Explorer, when selection is on your assembly project. 3) Show the "Properties" window of this project, the "Debug" tab. 4) Edit the field "Command line arguments", enter the start command for your application (VB6 or anything you use, the one which launches the application using your assembly). 5) In the source code of your assembly, set a breakpoint somewhere in your code you want to debug. 6) Click F5 or Debug -> Start Debugging.

Enjoy debugging.

—SA


From menu Debug->"Attach to.." option, please point the correct process ie, dllhost.exe COM Surrogate. and not win32 client....


这篇关于在VS2010中调试C#COM程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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