none
Visual Studio Programming 101

    Question

  • Hi,

    I am new student learning how to write C# program in Visual Studio.  Is it possible to create multiple exe programs within the same visual studio project?  When it compiles, does it generate two exe programs?

    Thanks, 

    Friday, May 06, 2016 3:11 AM

Answers

  • Hi Brandon,

    Files can be shared between projects but from my perspective, this is not a good pattern.

    To share a file between projects you right click the location where the file should be added (e.g. inside the project itself or inside a sub folder.) and choose Add -> Existing Item...

    Choose the file you want to add but instead of clicking the button "Add" you click on the small arrow next to it. Then you can choose Add as Link.

    That way the other file is also included in the 2nd project.

    You should take care with namespaces - if the projects have different default namespaces than this might cause trouble.

    With kind regards,

    Konrad

    • Marked as answer by Brandon.Ho Friday, May 06, 2016 4:43 AM
    Friday, May 06, 2016 4:38 AM
    Moderator

All replies

  • Hi,

    can you describe in detail what you want to do?

    A project creates only one exe file. But Visual Studio has the so called solution and that can contain multiple projects. That way you can create different exe files.

    With kind regards,

    Konrad

    Friday, May 06, 2016 4:14 AM
    Moderator
  • Yes, Visual Studio creates one exe file per project.  In the project, it creates app.config, exe, and other files on both bin and release folders.  I would like to create another exe program which would share the app.config common parameters and SQL connection configuration.  If I use Blend to copy VS project, when I change the contains in the app.config, I will have to update both app.config files.  If I share the folder, I don't have to change them in multiple folders.  

    Thanks,

    Friday, May 06, 2016 4:26 AM
  • Hi Brandon,

    Files can be shared between projects but from my perspective, this is not a good pattern.

    To share a file between projects you right click the location where the file should be added (e.g. inside the project itself or inside a sub folder.) and choose Add -> Existing Item...

    Choose the file you want to add but instead of clicking the button "Add" you click on the small arrow next to it. Then you can choose Add as Link.

    That way the other file is also included in the 2nd project.

    You should take care with namespaces - if the projects have different default namespaces than this might cause trouble.

    With kind regards,

    Konrad

    • Marked as answer by Brandon.Ho Friday, May 06, 2016 4:43 AM
    Friday, May 06, 2016 4:38 AM
    Moderator
  • I got it.  That should do the trick.  Thank you!
    Friday, May 06, 2016 4:45 AM