2

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?

Bilal Amjad
  • 149
  • 3
  • 11

2 Answers2

3

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.

Noctis
  • 11,507
  • 3
  • 43
  • 82
  • Noctis but now i'm facing another problem, that when i build the project it deploys both the solutions. Why it is so? I have merged the second solution in first and need only first one to work then why it is deploying them as separate projects? – Bilal Amjad Aug 30 '14 at 08:47
  • Because they are separate projects. each projects gets build into it's folder. Usually , if one uses another, one will be a `dll` that will be copied into the other's output directory. Not knowing more of what you're doing, it's hard to say. – Noctis Aug 30 '14 at 09:47
  • Actually i have developed a windows phone application and one of its module is developed by my friend and he have provided me that module as a separate project so i merge both and now i want to access the pages through each other. – Bilal Amjad Aug 30 '14 at 10:23
1

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 output 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 the 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 forum post

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Helper -Joe
  • 101
  • 6