Tinashe Tinashe - 1 year ago 100
C# Question

cant find exe in reference project

Helle, I have two projects(Project1 & Project2) and i am trying to run Project1 within Project2.

I created a form (Form1) in a project(Project1) and compiled it. Then I add the .exe file from project1 to project2 by adding it as a reference in the References folder in Solution Explorer, i declared a namespace

using Project1;

and tried to call using the following code:

System.Diagnostics.Process LoadProcess = new System.Diagnostics.Process();
LoadProcess.StartInfo.FileName = "Project1.Form1";

Then i get the error message cannot find file.

Answer Source

If you really want to start the Project1 with a Process you don't really need the reference in the solution explorer.

All you need is to put your *.exe file of your compiled Project1 which is probably called Project1.exe into the same folder where Project2.exe is. After that change this line:

LoadProcess.StartInfo.FileName = "Project1.exe";

The process needs a real filename with extension. Or the entire path to this file if it is in some other folder.

But if you have already a reference I would follow Lasse V. Karlsen's lead. The solution from his comment is a much more elegant and simple solution. Just use the Form1 in your code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download