Note that there are some explanatory texts on larger screens.

plurals
  1. POInvoking a second Visual Studio project programmatically
    primarykey
    data
    text
    <p>I'm working on a solution in Visual Studio 2010 Ultimate that contains two C# projects: a Forms project and a console project. Programmatically, they are completely separate; the main portion of both projects could run without the other. What I would like to do is invoke the console application by pressing a button in the Forms application, with certain options set based on the Forms application. So you can think of the Forms application as essentially just a 'launcher' app.</p> <p>The way I have this implemented right now is by using <code>System.Diagnostics.Process.Start</code> with <code>"cmd"</code> as the first parameter and the path to the console application's executable (plus CLI arguments) as the second parameter. But this is a terrible solution, because it will break when deployed to other machines with an installer. </p> <p>I've also tried creating a reference to the console project in the Forms object, making <code>Program</code> in the console project public and static, and calling the console project's <code>Main</code> method, but because there's no valid output handle, this eventually causes an exception to be thrown. </p> <p>I've done much Googling, some searching here on SO, and even checked the 'Similar Questions' on the submission page, and no one seems to know how to do what I want to do. Any pointers that could put me on the right track?</p> <p>FYI: I know that there's probably ten million better ways to do this, but I have several reasons for wanting and needing it done this way. I know I could just make a separate GUI for the CLI program and copy the relevant code over, or merge everything into one project and make a separate output window, or various other solutions like those. But I need this solution for two reasons: (1) I had a fairly complex CLI program that works well as a CLI program, and now need a user-friendly way to start it, and (2) solving the problem in other ways doesn't answer the question of "Why bother having several executable projects in the same solution in the first place if you can't invoke one from the other?"</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload