Reference DLL project from a different solution in VS Studio 2019? - c#

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.

Related

Reference Path in Visual Studio not working when I unload the project in the same solution

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.

How do I create a Shared Code project (.shproj)

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.

One or more project was not loaded properly

After copying the project to another laptop/ PC, when I want to open the solution, VS2010 shows the error "One or more project was not loaded properly". I have tried running visual studio in admin mode but that did not solve the problem.
This is usually a result of an inconsistency in your solution or projects. Open the solution file in an external editor (such as notepad) and check that the path it has to the projects is available and did not change. There shouldn't be any absolute paths in the solution file.
Maybe because the project from where you copied was configured with IIS configurations and you are trying to run the project in visual studio's default environment.
you have to right click on your project and set as a start up project after that you have run your project,
I seem to have found unloaded project, after noticing there's one missing by manually counting and comparing it to the number of projects the solution explorer reported. It was deep inside another folder in the solution explorer that I never used and assumed that had nothing worthwhile.
It's a familiar issue. Looks like the project you are trying to open was created in higher version than what you have. If the project is in MVC, make sure you have installed MVC OR Make sure you have appropriate version of .NET installed in your system.
I work with NopCommerce and a couple of times I downloaded new version and got same error message. It goes away once I install the dependencies.
Because you tagged it ASP.NET make sure you have all the ASP.NET components installed. Those are not part of .net framework but might be necessary in your project.

Error Message when Referencing .dll Files

I would like the use DirectInput in my XNA game however I'm having an issue when it comes to referencing the .dll file. I'm using Microsoft Visual Studio C# Express Edition. This is exactly what I do:
right click "References"
chose "add reference"
navigate to the .dll file and hit OK
I then receive the following error:
As stated above I would like to reference the Microsoft.DirectX.DirectInput namespace but I don't know which .dll file that it's in so I just picked the "d3dref9.dll". Every .dll file under that directory doesn't work though so any one I pick gives me the same error. Now I've been able to accomplish this with other .dll files but for some reason the DirectX ones wont work. I know it's possible beacuse this guy did it just look at the second line in his code.
I have the DirectX SDK installed why can't I reference any of the .dll files and how can I make it so I can?
Thanks!
The problem here is that you are adding a reference to a native DLL while managed projects only support managed DLLS. I believe the DLL you are looking for is Microsoft.DirectX.dll. That has the managed wrappers for DirectX
I think you are trying to reference .dlls that are not .NET assemblies, and/or not COM libraries.
This link might help with locating the propper .dlls:
(copy/paste from linked post:)
What you need to do is add the correct DLLs as references to your
project. Since they are not in the list, you'll have to add them
manually. I am assuming you are using the October SDK?
What you'll need to do is:
Right-click on References folder, and select "Add Reference..."
On the .NET tab, select the "Browse" button.
Navigate to where you installed the SDK. (On my machine it is C:\Program Files\Microsoft DirectX 9.0 SDK)
The files you are looking for should be in ".\Developer Runtime\x86\DirectX for Managed Code"
Select the DLLs that you want (in this case Microsoft.DirectX.dll, Microsoft.DirectX.DirectInput.dll)

How can I include files in a C# deployment?

I have a DLL I need to deploy with my C# application. It's not currently included in the installation package when I hit "Publish" so how do I include it?
Would the process be any different if I had app.config and other files I wanted to deploy with my application?
If it's referenced it should be included automatically. I've deployed a couple of apps that require a 3rd party dll and they've published OK.
Is the dll referenced correctly in your project? That's the only thing I can think of at the moment that might be the problem, but if it wasn't your code wouldn't compile and/or link anyway.
To get the xls file to deploy all you need to do is add the file to the solution and then set the "Copy to Output Directory" property on the file.
I take it you are using Visual Studio?
If your using Visual Studio 2008 (I have no experience with Visual Studio 2005) under the Publish tab in your project properties click on the Application Files button. This will bring up a list of all dependencies assembalies required by your project. If you find that required dll is not being published by the Visual Studio publisher tool by default you can go into here and set the Publish Status of the offending dll to Include.
Sometimes in my more complicated projects, depending on the type of dependency, I have to go into this menu and force certain dll's to be included opposed to the default Prerequsite setting.
...but this is all under the assumption you have the assembly properly referenced in the required projects and everything is compiling fine.
Can't you add the dll as a resource to your installer project?

Categories