0

I have two projects and two .exes as outputs of these projects. But I want to create one .exe file that can run both. How can I do this in Visual studio 2010?

Tooru
  • 13
  • 4

1 Answers1

0

Move the code from the second project to Class Library instead of an executable. Reference the new project from the first, and then call the code in the second when the first one runs. Your original second executable would also call the code in the new class library.

Two programs:

namespace ProgramA
{
    class Program
    {
        static void Main(string[] args)
        {
            // Do stuff A
        }
    }
}

namespace ProgramB
{
    class Program
    {
        static void Main(string[] args)
        {
            // Do stuff B
        }
    }
}

Move the code from the second into a class library:

public class ClassB
{
    public void DoStuff()
    {
        // Do stuff B
    }
}

Then call it from your first program and your second program:

namespace ProgramA
{
    class Program
    {
        static void Main(string[] args)
        {
            // Do stuff A

            // Do stuff B
            var classB = new ClassB();
            classB.DoStuff();
        }
    }
}

namespace ProgramB
{
    class Program
    {
        static void Main(string[] args)
        {
            // Do stuff B
            var classB = new ClassB();
            classB.DoStuff();
        }
    }
}
Jason
  • 651
  • 5
  • 10