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

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

Related

unable to add system reference to vs2015 project

I am trying to add Microsoft.CSharp and other system references to a c# class library in vs 2015 community edition bound to tfs. when i add it doesn't persist the path for this particular class library. All the references i add are highlighted in yellow !. The same references and paths I am able to add to other projects but not this current one I am facing an issue with.
I have created a new solution and tried. it still doesn't work.
However I would not want to create a new project file. Any suggestions or workarounds to solve this problem?
Your .csproj files might be "corrupted" somehow. I would create a new project file and then overwrite your existing project file so that it can be checked into TFS.
Create a new project and copy all of your source files into the folder. If you have folders use Visual Studio to re-create them. Use the show hidden button in Solution Explorer to show all the files. Now include the files by right clicking and selecting include in project (you can use Shift to select multiple files). Check your project properties and make sure you copy anything important.
I tried a few things-
I changed from community edition to professional edition 2015. the same problem persisted.
I created a new csproj file and added back the files manually. It got added fine.
However I am pulling the references from a nuget packages folder and updating. if we have the wrong path to the nuget packages, even though we add the references, they were being shown as not referenced.
The nuget packages needed to be correctly mapped or else VS2K15 acts weird.
So bottom line, because my nuget references were incorrect it was throwing these errors. I know This is very weird!!!

Adding references in monodevelop

In simply words i cant add reference in mono project the button "edit reference" in project menu is not active, i tryied to make new project and paste my code but button was still not active? How coudl i add reference?
You've probably got it already, still if anyone else comes across it- you need to make sure you select the project (to which you wish to add references) in the solution view and then add references (by either going to Project then Edit references or right clicking on the project); as long as the solution is selected in this view the edit references menu item will be disabled.
Go to Edit references(you can get this by right clicking on the reference icon). If you would like to add a package, you can do that by selecting the require package under the package tab.But, if you would like to add the reference from a local project library, go to the .Net Assembly tab and browse for the location of the .dll file (most often it will be in the bin folder of that local library project), and add it to your 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.

Problem in Subversion

I Implement subversion for first time for test in 2 computers.In a Client Computer I work in a working copy of a project.in this project i add a Devxcomponent (button) in my form and then commit project and send newly version on the server.When I open an updated working copy of project in server ,my project has an error in references Section and show a yellow error in my new dll component.how can i fix this problem?
Try to check if you're not using any third-party dll. If so, it must be commited as well. You can create a folder named dll and add your button dll on it. Commit that folder. When you update in server, just add the reference again to that dll.
Did you miss checking in the dll reference? You must do a svn add on files that you add to your project as references and commit them as well. Also you say you added the Devxcomponent (button) - did that involve adding a new file? You have to add that as well.
Since you are using TortoiseSVN:
Right click on your project -> TortoiseSVN -> Check for Modifications.
Look for non-versioned items. If the file / folder is non-versioned which is needed by your project, right click on it and click Add and then commit.

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