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.
Related
I am running a C# web api project on Visual Studio 2019. The project is set up to pull a particular dependency from NuGet. However, I want that particular dependency to point to a local dll I have on my local machine that was built via another VS2019 solution.
When I try to reference it via a HintPath within ItemGroup it still appears to reference the binary from NuGet. I've also tried copy pasting the dll into the directory from which the project runs but am met with this error:
Any help would be appreciated. Thanks!
You make a right click on references in your project and click on "Add Reference". Then click on "Browse" and select your local dll.
I have an ASP.NET MVC project with one solution and 52 projects in the same solution. As you know, It takes long time to build whole solution. So I decided to unload some of the projects until there is some change or sprint task in the code in the unloaded project. However we are a team and use TFS version control and we need to use update unloaded assembly. So I have a build server that makes me sure whenever somebody starts to check-in (for example -> C:\bin in our network) the last version of all assembly can be found there.
I added C:\bin path as Reference Path to the UI Project (main project of the solution) of the solution and I expect when some projects is unloaded the reference comes to visual studio from the build server path (C:\bin) otherwise the reference of the project comes to Visual Studio from the nested project (not from build server).
But the reference can not be found when the project is unloaded:
And my Build server contains the assembly:
Finally I found a way (only in Visual Studio 2019) to unload projects and however use updated class library of unloaded projects. And thanks to Hooman Bahreini for his idea of using two separated solutions.
The way is that, there is a feature of Visual Studio 2019 that we can Save As Solution Filter which is in .slnf extensions. So I can unload some of my projects and check-in .slnf file via my source control (like tfs). So I have two solutions Now, one is .sln which is contains all of projects and the other one is .slnf which is unloaded some of projects in it.
The things can we do is that whenever I want to get my project I have to use .sln file and builds that and then close the file and then open the .slnf file (I'm sure that I have updated class library of unloaded projects) and do my task and check-in my changes.
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)
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 want to use ObjectListView in a project coded in VS 2010.
Therefore I did the following things:
Downloaded the project
Opened both ObjectListView.sln to convert it to a VS2010 project
Added one of them to my project-folder in VS 2010
Added the project-assembly to my project
Added the namespace xmlns:o="clr-namespace:BrightIdeasSoftware;assembly=ObjectListView"
It compiles but it doesn't find any of its classes in my project. That means after entering the namespace: "
Does anyone know what I can do about that?
The ObjectListView project in the solution is missing "Filters.cs". It's located in the directory, just not added to the project.
Add it to the project, and everything will build (using VS2010, and ObjectListView.sln).
EDIT:
It looks like you're creating a WPF project. ObjectListView is intended to be used in WinForms applications.