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.
Related
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.
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
I made a user control library with one control in it, and added it to a winforms project. It showed up in the toolbox under a tab named after the control library automatically. Then I added 2 controls to the lib, and built it, and when I opened the winforms project, it didn't show up in the toolbox, and I found this question and put it back in the toolbox by right clicking it, and clicking "choose items" and going to the library's bin directory. But it showed up only in the all controls tab. My question is, why did it stop doing it automatically and why does it not have its own tab anymore (previously it had its own tab)?
Just a few thoughts I mentally go through and hope resolves your issue.
Yes, I too have a separate "control library" dll, and it has subclassed Textbox, Checkbox, label, etc...
Each of the classes is declared as PUBLIC.
Each class as a zero parameter constructor() as a default, even though implied otherwise.
That said, my "Solution" has the main "Windows Application" project. I then ADD the OTHER (Control Class library PROJECT), if yours is not already, INTO the solution.
Then, in my main project's, I did an Add Reference. This brings up the dialog of the locations to pick from including .Net, COM, Projects, Browse and Recent. I make sure that I reference the "Project" and it should list all projects within your solution. I do NOT just pick the physical .DLL where you may have built the project otherwise.
Then, under the menu, I do "Build" / "CLEAN SOLUTION". This forces all other dependency projects to get their DLL rebuilt and reloaded, THEN the main project of the solution is rebuilt.
After doing so, all the controls SHOULD get refreshed into the toolbar, such as when you bring a main project window up for adding your controls. The toolbar SHOULD auto-load the toolbar controls based on the project dlls associated with your solution...
It might just be one missing step that has you hung...
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.
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.