This question already has answers here:
What is the difference between a Shared Project and a Class Library in Visual Studio 2015?
(6 answers)
Closed 6 years ago.
What are the practical implications of adding a normal Project (WPF Application, Windows Forms Application, etc...) vs a Shared Project as a reference in Visual Studio 2015?
I know that Shared Projects are a rather new (since VS 2013) and presumably superior feature, so I would like to know all differences.
Could one difference be that files in the Shared Project can use code from projects where the Shared Project is added as a reference if all of those projects do have the code to be used?
This is not possible in a normal Project of course.
Also for some reason Visual Studio shows me far less suggestions if I do "Add -> New Item..." on a Shared Project.
As a sum up of differences found so far (take that with a grain of salt as I'm not an expert):
Shared Projects vs normal Projects (Class Library, WPF Application, Windows Forms Applications, etc...) added as a reference:
Files in Shared Projects can use code from projects where the Shared Project is added as a reference if all of those projects do have the code to be used.
Shared Projects do have less suggestions when "Add -> New Item..." as they are more generic.
Shared Projects are not compiled to .dll or .exe but added with source code to the project referencing them and therefore can be debugged step by step.
Project, assuming a class library, will be compiled and the dll will be referenced from the other project. Shared Projects are fancy way of file linking (or copy pasting the code file when compiling). This has benefits as in you can have access source code that is not only in shared project but also in the target project (as long it works for all referenced projects). But can also give conflicts if using this in an library that will be referenced in your target projecct too. I think you best can go for a normal class library and only use shared project if you are really sure you needed (was introduced to have better code sharing between your win8.1 and wp8.1 app)
Related
I have seen similar questions, but the solutions seem to be deprecated or not compatible with VS Studio 2019.
Basically, I am building a client and a server application. I am building each one in a separate solution.
In the client solution, I added a Class Library project, which includes some classes I'll need to use in the server solution.
So, I right clicked on References in my solution explorer, and tried to find the solution. I browsed to the supposed location of the DLL in the first solution, but the problem is that there doesn't seem to be any .DLL file despite the project being a "Class Library (dll)". The only file is ClassName.csproj and I can't add that one. I also can't manually add the .cs files since it says its not a dll.
How I add a .shproj to my Visual Studio solution and reference it from other projects?
I know that Visual Studio 2013 Update 2 added a new project type for "Shared Code." This type of project does not produce a dll itself. Instead the files from the Shared project are included as source files in the assemblies that reference it.
I know it exists because I have seen one in an open source project. However, looking through the project templates in Visual Studio I could not find a "Shared" project type.
Edit: According to the Visual Studio 2015 Preview documentation, VS 2015 adds templates for shared projects and a UI for managing the references, so the below should no longer be necessary after upgrading.
There does not seem to be a way to create one directly. It appears currently that Shared Code projects are automatically created when you create a Universal App project as shown in this introduction to creating a Universal App.
Therefore, to create one in your solution: Add a new project type "Blank App (Universal App)." Delete the Windows 8 and Windows Phone projects it created leaving only the Shared project.
Check out the Shared Project Reference Manager extension.
Note: make sure you have VS2013 update 2 or above for this to work.
An alternative to vossad01's approach is to create a shared code project, then open up the .csproj file and see what the project looks like in the .csproj. Visual Studio's csproj files are simply XML files so you can open, copy, and paste the shared code project into your own csproj.
I am trying to learn to write my codes in libraries and compile them into DLLs in C#.
This is what I do:
I have a main VS project in which I piece up the different parts of the application that I am writing.
I write my classes in separate VS projects. Then, I compile them into DLLs, which I will copy the DLLs to the main VS project. The main VS project will make references to these DLLs and then use them in its logic.
The problem, however, is that when there is a bug or issues with the codes compiled in the DLL, it becomes very difficult to debug. The compiler won't tell where exactly the error came from. Also, when I make changes to the classes resided in the DLLs, I have to always recompile and replace them when working on the main VS project.
My workflow becomes very obtrusive this way. What should the correct workflow be when working with DLLs?
Add the DLL project(s) to the solution file which contains the main project and you will be able to break into that code with the debugger (right click solution -> add existing project).
To build an Autocad application I use C# 4.0.
My application has two module one for 2005 and another for 2010 autocad. it uses special dll's of autocad ,but face some difficulty of finishing it up .All should be universal for 2005 and 2010 autocad since dll's has the same name it was impossible for the app to differ autocad versions.it create problem for autocad interop dll's in reference.help me to use different dll for different module.
Application has two modules(2005,2010)
Special dll
2005 and 2010 dll has same name.
Application fail to distinguish dll
Help me to use different same name dll in one application.
Note:In individual project they work perfectly.
need help to use same name dll in one application .
If have any query please ask ,Thanks in advanced.
I've a similar application, it works for autocad from 2006 to 2013 (both x86 and x64) and for bricscad v12-v13.
To solve it I did a visual studio project for each architecture, each of those projects refers different .dll depending on autocad version. In particular each of those projects refers AcDbMgd.dll, AcMgd.dll, Autodesk.AutoCAD.Interop and Autodesk.AutoCAD.Interop.Common, those dll are specific for each autocad architecture.
You have to pay attention that all of the referenced dll are in copy local FALSE!
In my case all the projects are compiled in different folders but it's not obligatory if you assign a different assembly name for each project.
Thanks to the fact that AutoCAD API are the same from 2006 to 2012 (2013 has some differences), the source code is separated from those projects, each project include it as a linked source file (go to the project in the solution explorer -> right click -> add existing item -> select the source file and press "add as link"). In this way you have the same source code for all the projects but they are compiled including different autocad dlls.
In my case there were also some troubles because BricsCAD has sometimes different API with respect to AutoCAD. To solve this few cases I've set a conditional compilation symbol and used it like so:
#if BricsCad
CADAPI.ApplicationServices.Application.SystemVariableChanged += new CADAPI.ApplicationServices.SystemVariableChangedEventHandler(Application_SystemVariableChanged);
#else
CADDB.LayoutManager.Current.LayoutSwitched += new CADDB.LayoutEventHandler(Current_LayoutSwitched);
#endif
Tell me if you need further information. BTW I think your main problem is the copy local = true for autocad Dlls.
I have project A, a C# console application which I want to reference my project B, a C# class library. My goal is to be able to make use of objects in Project B from within Project A, and see the source tree for both projects in the same Solution Explorer. I can of course make a reference from Project A to the built .dll that Project B outputs and use the objects in that fashion, but this doesn't give me the control I would like.
I'm having difficulty achieving this. I assume it should be found in Add Reference -> 'Project' tab, but I don't see any items in that tab window and can't figure out how to populate it. Am I missing something here? Both projects target .NET 4.0 framework and I am using Microsoft Visual Studio 2010 Version 10.0.40219.1 C# Express with ENU Service Pack 1 (KB983509).
Any help would be appreciated, thank you.
Open Project A
File - Add - Existing Project
Open the .csproj file for Project B
You should now be able to see the source for both projects as part of the same solution.
Now from Project A:
Add Reference
Go to Projects tab
Select Project B
Project A will now be able to use the types declared in Project B.
Open Project A, File > Add > Existing Project
Both projects need to be in the same solution.