Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2009-06-29
5
622 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

791 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