ispiro
ispiro

Reputation: 27673

How do I call a second project from the startup one in visual studio?

I have a startup project and I want to do a process.Start(); on a second project in the same solution. But using Path.Combine(Application.StartupPath, "SecondAssemblyName.exe"); as FileName doesn't work. What does?

Upvotes: 0

Views: 469

Answers (3)

CodingWithSpike
CodingWithSpike

Reputation: 43718

By default, each project builds to its own directory, so you would have something like:

\MySolution
    \ProjectOne
        \bin
            ProjectOne.exe
    \ProjectTwo
        \bin
            ProjectTwo.exe

So your command to execute the other .exe does not work because they are built to separate folders.

You can fix this by doing one of a few things. You can add a post-build step to copy one .exe to the others \bin folder. Or you could change the build output paths of the projects to build to the same location.

Upvotes: 3

Reed Copsey
Reed Copsey

Reputation: 564413

You can use Process.Start, but you need to supply the correct path to the other project.

This simplest solution would be to change the output folder in the build settings for each project. If you build both projects to a shared output folder, you can just use Process.Start as you entered.

Upvotes: 1

NewCastle79
NewCastle79

Reputation: 73

you can start two project on debug doing the following:

click under solution -> Set StartUp Projects

in the windows opened click in Startup Project.

Select the option multiple startup projects and select the projects.

So you can run both as same time at debug and running into visual studio

Upvotes: 0

Related Questions