How to add multiple solution reference in Visual Studio - c#

This is more like a beginner question, but till now I have worked on small C# projects and I know how to add a separate project.
I will create a class library, and add reference of it as per needed, and then I am good to go. I will have something like below:
Project Main -> references Project Temp1
-> references Project Temp2
But all this when built will form ONE .sln file.
Question: how can I link separate .sln? So, I have 5 separate Visual Studio solutions, and I want to add reference, how to achieve it? Is it possible for one .sln file to link to another .sln file?
Edit: I created a sample application A1, and another application B1. And now when I go to Project A1 and click on Add reference why don't I see project B1 there?

Your screenshot shows the reference manager with item "Projects > (current) Solution" open. This list shows all projects in currently opened solution. To see your "B1" project here, add it to solution first:
Solution Explorer
Right click on Solution
Add > Existing Project

Related

How to create new project for current class library without having to create a solution?

I have setup an class library project in visual studio so I can make a custom hyperlink [the built in one doesn't have what i need]. I want to now make a demo project to test it but I want to be able to do it without having to create a whole new project. How can I do that?
For what you want you just need to create a new project in the same solution.
If the solution is not seen in the Solution Explorer, you can enable the option to always show it here:
Open the Tools menu.
Press the Options item.
Expand the Projects and Solutions tree node and select the General tree node.
Tick the Always show solution check box.
Now you can just right-click your solution in the Solution Explorer and press Add and New project.
MSDN Reference to adding projects to a solution: https://msdn.microsoft.com/en-us/library/ff460187(v=vs.100).aspx
Whenever you create almost any type of new project in Visual Studio, a Solution is created for you;
A Solution is a structure for organizing projects in Visual Studio...
This means that multiple Projects (and Projects of different types) can exist within a single Solution. You can see the link above for steps on how to do this, or you can follow the steps listed below:
Open Solution Explorer from the View menu in Visual Studio [if it isn't already open];
Right-click the Solution in Solution Explorer. The Solution, as far as I am aware, is always the first item in the list;
Navigate to Add > New Project...:
;
Follow the steps to create your desired Project;
And that's it.
Don't forget to right-click the new Project in Solution Explorer and select Set as StartUp Project if you want to Run or Debug it:

How do you add someone else's project to your current project?

I'm trying to use this color dialog written by someone else in my program but I don't know how to integrate it. I'm very new to C# so I am not really sure what I'm doing.
http://www.codeproject.com/Articles/33001/WPF-A-Simple-Color-Picker-With-Preview
I would recommend that for third-party code, you do not integrate their source code directly into your own project, but an assembly reference to the compiled foreign code. This makes it easier to separate your code from third-party code, and update the third-party code later on if a new version becomes available.
So this is roughly what you do.
First, create an assembly from the third-party code (the color picker source code):
Download the source code.
Open the Visual Studio solution (.sln) hopefully present in the download.
Create a Release build. (This might require you first changing the build configuration to Release via the Build menu in Visual Studio.)
After a successful build, there should now be the color picker DLL in the bin\Release folder.
2. Next, add the created assembly (.dll) into your own project and reference it:
Put a copy of that DLL into your own solution/project's directory.
In your own project, add an assembly reference to that assembly (via the Solution Explorer window's References node's context menu).
Open your project in the solution explorer, right click on References, click on Add reference, select Browse and add it.
To add an existing project to a solution:
In Solution Explorer, select the solution or the solution folder that you want to add a project to.
Right click, select Add and then choose Existing Project.
Select the project you want to add to the solution and then click Open.
To add an assembly reference to an existing
Right click on References in your project in Solution Explorer
Select Add Reference.
Select Browse and navigate to the assembly

how insert form from project other in visual c#

I have a Project in which there is a form that has several objects (controls) in itself. I want to add this form to another Project in another Solution. How to I can do this. Thanks.
This is a good thing to reuse your code :)
You have to make a library project.
1)File => New Project
2)Check Visual project in the tree
then select "Class Library", give it a name "MyFormLib"
3)Then simply copy paste YourForm.cs and YourForm.designer from your app project, to "MyFormLib".
4)Now go to solution explorer, browse to your application project, right click on "references" then "add reference"
5)To finish click on "solution" then choose your library project "MyFormLib"
.
6)You can now use the form from the library project inside your application project.
e.g : new MyFormLib.TheForm()
7) To reuse your form in your second application, redo steps 4 to 6
Just simply open the project where you want to add the existing form:
Right click on the Solution Explorer
Select "Add" -> "Existing Item..."
Browse your other project's folder, and search for the 3 files of your form:
yourForm1.cs, yourForm1.Designer.cs, yourForm1.resx
The simplest way is to
Open the destination solution in Visual Studio.
On the Solution Explorer, right-click the destination Solution name and Click on Add > Existing Projects. Identify the project with your source Form.
Move the form from source to destination project (The designer and resx files will move with it)
Change relevant namespace specifications and then you may remove the old form.

How to import a class from another project in Visual Studio 2013 Ultimate

I am completely new to using Visual Studio 2013 Ultimate and C# and I am trying to figure out how to simply import a class that exists in another project into my console application.
I have another project named Project1 that contains a CreditCard.cs file. I have tried the following for importing the CreditCard class:
typing using Project1.CreditCard
going to the Solution Explorer and then looking for "References" which I could not find, to try to include the class as an imported class.
Can anyone please point me in the right direction or tell me how I might import a class in C#?
You right click on the project (not solution) that you want having the reference. So click on your new project, choose Add | References --- then in the dialog, choose Solution on the left, and find your CreditCard project and add it. It'll add the reference, and you can then use the Using in your code.
in solution explorer, right click on your project and go to add ==> existing item, then browse to the path of your existing class.
When you say another project do you mean two projects in the same solution? if so, you have to reference the project(Project1) with the class in the other project(Project2) by doing so:
Left click on the project(Project2) that you want to add the reference
Go to Add -> Reference -> Solution
Target the project(Project1) you want to add and click OK
Now in your project(Project2) you can do "using Project1(name of your project)" or "using Project1.FolderName" if your class is in a folder to use that class and then:
CreditCard creditCard = new CreditCard();

Add codebase as reference instead of copy Visual Studio

This may be a ridiculous question for you C# pros but here I go. I'm a Flash developer getting started in Silverlight and I'm trying to figure out how to create a "codebase" (a reusable set of classes) for animation. I'd like to store it in a single location and reuse it across a bunch of different projects. Normally in Flash I would add a "project path" reference and then start using the code. My question is, how do I add a folder to visual studio so that I can "use" those classes in my project. I tried "Add > Existing Item" but that copied the files into my project directory.
The easiest way would to create a new ClassLibrary project and build it. This will output a .dll file in a folder you can specify in the project settings menus, which you reference from every project that needs it.
Also, you can copy this .dll into the /bin/ folder of your project - this will do the same thing for this specific project, but when you start the next one you can change some details in the codebase library without breaking the first project.
The solution described by Tomas (adding a reference to a dll binary) is the correct solution to this problem; better than referencing the source code and compiling it into each project.
But just for extra information, if you ever do need to add a source code file to your Visual Studio project without having it make a copy of the file you can use the following steps:
Right click on your project in Solution Explorer and select Add -> Existing Item.
Navigate to the location of the source code file and select it.
On the "Add" button in the dialog window there is a drop down arrow. Click this and select "Add as Link".
This will allow you to use this source code file in your project without having VS make a copy of the file.
In Solution Explorer, right-click on the project node and click Add Reference.
In the Add Reference dialog box, select the tab indicating the type of component you want to reference. (for instance for a class library a dll)
Select the components you want to reference, then click OK.

Categories