Merging Two Projects and accessing files from each other in Visual Studio

假如想象 提交于 2019-12-23 04:44:15

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/25580314/merging-two-projects-and-accessing-files-from-each-other-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!