Solved

Breakpoints NOT hit when console application run through System.Diagnostics.Process

Posted on 2009-06-29
5
614 Views
Last Modified: 2012-05-07
Hi there,

I have a simple console application which is running fine (.NET 2.0 and Visual Studio 2005). I have placed some breakpoints within the console application and these breakpoints are hit when I execute the console application through visual studio by marking the console project as startup project.  Till this point everthing is fine.

But when I tried to execute the console project using WindowsForm which is using Process() to execute the console project. The console project is running fine with process.Start(), but the problem is that the breakpoints within the console application are NOT hit when I execute the console application through Process() class. I will be thankful for your help.
0
Comment
Question by:tech1guy
  • 3
  • 2
5 Comments
 
LVL 39

Expert Comment

by:abel
ID: 24739838
Breakpoints are only hit when you attach a debugger to them. To attach a debugger, you will have to go to Visual Studio after you used Process.Start and then you can select Debug > Attach to Process. From then on, when a break point is hit, it will show in the debugger of Visual Studio.

0
 

Author Comment

by:tech1guy
ID: 24739906
which process I need to attach? When I try to attach the TestForm.exe (where I am calling console app through Process), it says that it is already attached. I am executing through F5.
Moreover, is there a way to programaticaaly attach the debugger to Procees?
0
 
LVL 39

Expert Comment

by:abel
ID: 24740433
It is probably possible to programmatically attach the debugger.

It seems to me that we're mixing two things here. You have one process, let's call it procA.exe and you have another process, which you call TestForm.exe. The second process uses a Process.Start(procA.exe) to start the first process. When you debug TestForm.exe, you cannot debug another process with the same debugger. Either run Testform.exe the normal way (from Explorer) or open a new Visual Studio instance and select Attach To Process in that one, in which way you can debug multiple processes at the same time.
0
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24740479
As an alternative, you can try to put the following line somewhere in the beginning of your application procA.exe:

System.Diagnostics.Debugger.Launch()

which will popup with a request for debugging, or not if you have already set it to use the default.

ScreenShot413.png
0
 

Author Closing Comment

by:tech1guy
ID: 31598102
Thanks for the help!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
c# string 6 39
Unit testing, moq, best practices 7 28
Linq help 1 16
How to connect to a remote mysql server using C#? 9 42
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now