Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Debug console application while Process class to execute console

Posted on 2009-06-29
4
Medium Priority
?
603 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 2000 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

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 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