Click here to Skip to main content
15,867,141 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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
Posted
Comments
Sergey Alexandrovich Kryukov 26-Jul-13 16:39pm    
First of all, why COM? What are you trying to achieve with that? Any specific reason to use VB6? Well, get rid of the dead body as soon as you can.
And what's the problem of debugging? C# assembly is supposed to be debugged no matter how it is hosted. And it's usually very simple.
—SA
2006 Flauzer 26-Jul-13 17:42pm    
Hi Sergey, my goal is to make an ActiveX in .NET. There is a specific task to provide a way to an old app to "speak" with another .NET app, so ActiveX it's an easy workaround(and 'been decided...)

My surprise is that on MsgBox( Obj.Foo()) call, VS provides the correct result but I can't activate the debug and I cannot figure out what is wrong !!!

Step 2) ***Make your assembly project a startup project ("Set a StartUp Project" in context ...

The project is dll Class Library....i've an error on this. Anyway....

I've specified options2 ie the win32 app..."Command line arguments". all works well (ie I see the messagebox with result), but the debugger does not start !. Your solution is exacly what i've done, but it doesn't works...O_O
Sergey Alexandrovich Kryukov 26-Jul-13 18:46pm    
You see, your "to make an ActiveX in .NET" could not be an ultimate goal. The ultimate goal could be to achieve some ultimate result. ActiveX is way too obsolete and ugly relative to .NET.
It's hard to say what did you do wrong. See debug options... Re-install the Studio...
—SA
2006 Flauzer 29-Jul-13 6:01am    
Thanks Sergey for your interest and for your response.
Only a final comment, hoping to be helpful for those who have my same problem (due to the ignorance of all the twists and turns of VS .. maybe ..)

** It's possible to run the debugger using the "ATTACH TO.." menù and point to the correct dllhost.exe (COM Surrogate) related to the ActiveX; ***
and don't forget to remove the code optimizations check box...

However, for me the question remains open, ie if someone tries to build an AX in C# and go to debug with simpke F5 press button .. the thing is not so immediate ...

Thank you.
Flavio
Sergey Alexandrovich Kryukov 29-Jul-13 10:13am    
You see, I just don't understand what prevents you from debugging. Attaching to a process certainly work, and I suggested some simpler way of debugging in my answer, which should work for you. Did you try it?
—SA

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
 
Share this answer
 
From menu Debug->"Attach to.." option, please point the correct process ie, dllhost.exe COM Surrogate. and not win32 client....
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900