Merging Two Projects and accessing files from each

2019-06-12 15:13发布

I have merged another project in my existing project by right-clicking on the project name and selecting Add->Existing project option. Now i wan't to access the files from my newly added project from the existing one in Visual Studio (Its a C# project) , how can i do this?

2条回答
看我几分像从前
2楼-- · 2019-06-12 15:45

I struggle with this until I found this the link is below:

If you want all windows application to run as one program rather then calling multiple .exe. Then change 'Out Put Type' of each project to 'Class Library'.

Step 1:

You can do that by right clicking on each Project in solution -> Go to Properties -> Application -> Out Put Type... set it to Class Library

Once you have done that out put of these will be generated as .DLL.

Step2:

Add a new Window Form application project, add reference of exiting projects in it so that they can be executed from here.. you can do that by.. right click on main project-> Add Reference->Projects select all existing projects from here..

Now on main application you can create 3 buttons to launch each project...

[Inventory]

[Accounts]

[Payroll]

Now in each button code will be something like that...

Inventory_click()

{

Inventory.MainForm frm=new Inventory.MainForm();

frm.show();

}

Credit goes to:

https://social.msdn.microsoft.com/Forums/en-US/c1ccccc7-13e0-415c-9ccc-492bdfc9983d/c-application-multiple-projects-in-one-solution?forum=csharpgeneral Hope this helps

查看更多
SAY GOODBYE
3楼-- · 2019-06-12 15:49

If I'm following your question, you had a solution with a project A. You then added an existing project B.
You now want to access a file from A in B. If that's the case, right click on the B -> References and add a reference to project A. Now you can use the files from that project.


Edit: From your comment, I'm not sure if you want to have a separate project / file. If you want them to be only 1, you shouldn't really add a new project, you should add to your project A the files you need from project B. If you want to keep it as a different module that is included, then the above holds, but you need to realize that usually you have one solution, with many projects inside of it.

查看更多
登录 后发表回答