Solved

Debug console application while Process class to execute console

Posted on 2009-06-29
4
594 Views
Last Modified: 2013-11-26
Hi there,

I have a simple console application which is running fine. 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
  • 2
  • 2
4 Comments
 
LVL 33

Expert Comment

by:Todd Gerbert
ID: 24739850
You need to attach the debugger to an external process.  After your console application's Procress.Start() is called, go to Tools menu in Visual Studio, then choose Attach to Process.

If you need time to attach the debugger, you may want to introduce dialog box in your console application to cause it to "pause" until you click OK (during which time you can get the debugger attached)!
0
 

Author Comment

by:tech1guy
ID: 24739898
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 33

Accepted Solution

by:
Todd Gerbert earned 500 total points
ID: 24739951
Process.Start() has the same basic effect as double-clicking an icon on your desktop, Visual Studio won't automatically debug it because of the way you're starting it.

1) You'll probably need to start a new instance of Visual Studio to debug the console application.
2) Attach to the console process that's being Process.Start()'ed.
3) Don't think so.
0
 

Author Closing Comment

by:tech1guy
ID: 31598098
Thanks for the information.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

863 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

24 Experts available now in Live!

Get 1:1 Help Now