merging two c# project-need to insert 1 into the other - c#

here's the list of projects I have:
I need to insert the weather and maps into the PL.
I've tried several things and came up empty(I saw what was suggested to people who asked similar question but it didn't work for my situation).
any ideas?it's for a project I make and I need to submit it in a few days.

If you have resharper plugin installed in VS then you can select all the files and folder. Then press F6(or right click selection refactor->move).
Otherwise you would have to move all the files manually by dragging to one project to other.

If you're trying to merge the code bases, there's no easy way to do that. You'll just have to go one file or folder at a time, update the namespaces, resolve any conflicting names etc.
If you want to just use the functionality within your other projects, you can add a project reference to them from the consuming project. You can do this via References -> Right click -> Add Reference -> Solution Tab -> Tick the projects you want to reference -> Ok

Related

How to add multiple solution reference in Visual Studio

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

debugging several projects in Visual Studio 2017

I have a solution mainly written in c sharp. This solution has 10 projects, one of them contains the web forms. This web forms get the data from another project. However, I am receiving null data. In order to debug this, I would like to setup the web forms project as the start project but the problem that I'm getting is that I don't see what is going on on the other project, the one that passes the data. How can I reach this project when debugging? Any solutions? The other project just contains classes, it is not dealing with the database either yet.
Thanks
Have you tried to set the solution to start multiple projects at once?
Right click on "Solution Explorer", click on "Properties", select "Multiple startup projects" and choose what projects you want to start together by changing the dropdow from "none" to "start". It should work.
sorted! it was a silly mistake, the interface was misspelled, it should be IClass, being Class the class name, somehow, it was misspelled

Using a Form in a separate Project [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Has anyone successfully been able to use a form created in one project in another with VS2015?
I have created many forms that I usually need to include in most of my projects, however whenever I try to add them to the new project I can never seem to get them to work.
I would like to add them to a separate project, with their code and designer/image references etc, but I have only been successful in adding the form with code no resources or designer.
Instead I am currently having to manually re-create the same form in a new project and copy and paste and reset all the controls and labels and what not in the newer solution.
In the past I used to do it like this guy did: https://www.youtube.com/watch?v=FPBMoibAmU0 But it doesn't seem to work with VS2015?
Surely there's a simple way to do this? My way works but it's very time consuming and I think unnecessary.
So what I used to do in the past: Copy the form1.Designer.cs, form1.cs into the new solutions directory, then in the new solution, right-click the project properties, add existing file and browse and select the two files and click OK.
Yes, people re-use code all the time, this question is coming from a fundamental misunderstanding about how code and projects work. Code intended to be shared should be created in a shared project or shared/distributed library.
Using a distributed library:
Create a class library (.dll)
Add a reference to System.Windows.Forms
Define any code, forms, resources that are intended to be re-used here.
Compile library and retrieve .dll file.
Copy .dll file into your new project and add a reference to it.
Use the form.
This is essentially how the nuget package manager works except it handles managing the physical .dll files and adding of references automatically. If you will be the only consumer of this and you don't intend to check your source code into a source control server (git, tfs, svn, etc) then you could also store this dll only in a single location (your documents folder, etc) so updating it is easier.
If you want to be able to make changes to the original source code in all the projects that use the form, you can instead add the original shared lib project to your new VS solution by right clicking on your solution, clicking add existing project, and navigating to the csproj file of your library project.
Wow I finally worked it out,
To add a existing form of another project to current:
Right-click the Project Properties in Solution Explorer.
Click "Add".
Click "Existing Item".
Browse only for the "Form1.cs" and select it, Click "OK".
Right click the added "Form1.cs" and select "View Code".
Look at top for "namespace", highlight the actual namespace eg: "namespace Form1", so highlight "Form1".
Right-click highlighted namespace and select "Rename...".
A box appears, tick "Include Comments", "Include Strings", then type the new name in(with still the Rename box visible) and Click "OK".
Now just add the resource files to the current project.

Reuse a solution for a new task

I am new to C# and Sharepoint Web Services. I wrote a program awhile back, and I want to use that program as my starting point for the next project. It has all the references and resources already in place. Essentially, I want to copy the solution, and rename it, then change it to meet my current needs.
What's the best way to do that?
Try this:
open Windows Explorer, copy your solution and its folders, paste into a new location.
rename your copied .sln to something else (hit key F2 from Windows Explorer)
open that copied solution, and rename the solution (and perhaps your projects within)
You can open the old project in visual studio and then go to File --> Export Template and follow the wizard.
This will allow you to create a project template that will then be available with all your other project templates in File --> New project.
You can do this per project (or per item which will not help in your case). It then automatically renames your namespaces etc. if the template is configured correctly.
The most straight-forward approach would probably be to just create a new solution, then manually copy all the projects under that solution and add to the new solution (right click on the solution name in Solution Explorer -> Add -> Existing Project.
From there, rename the projects if required, being careful to keep things like the Default namespace and Assembly name consistent with your new project name (you can find these under each project's properties page). Also keep an eye out for any paths that might need changed in the pre / post build steps. You will probably also want to rename the existing namespaces (right-click the namespace in code, Refactor -> Rename...)
Also, this might be a good opportunity to spot which projects will be common to both the old application and your new one, and possibly moving these to a third location from which both solutions can reference them.

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