Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-06-29
5
Medium Priority
?
669 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
[X]
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
  • 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 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

609 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