Visual Studio - Referencing third party DLL - c#

I am using Visual Studio 10 within a C# MVC appliction.
I have a qustion on a .dll reference. I am using a third party reference called
Ionic.Zip.dll. What I am not sure about is that it currently points to a location on my C: drive.
How and what is the best practice for me to put this .dll so that when I check in the project, others can also see this .dll without it blowing up.
Thanks

I would typically put a Library folder in my application structure, place the 3rd party dll in that folder, and then reference that dll. Then ensure that the library folder is checked into your source control.
Now, anyone that pulls your source will have the required dll.

Even easier...simply add a reference to DotNetZip via NuGet, the Visual Studio Package Manager:
http://nuget.org/packages/DotNetZip
And you shouldn't have to worry about it.

The best way is to use Nuget.
But in some cases Nuget is not available or not getting compative, so as our friend says, its better put a Library folder in application structure, place the 3rd party dll in that folder, and then reference that dll. Then ensure that the library folder is checked into source control. Now, anyone that pulls source will have the required dll.

Related

Set up dependency resolution properly

I have a c# mvc project (mvc) which depends on a self created dll (dll) and this self created dll depends on some 3rd party dlls (3rd). When I build the mvc project, it triggers the build of the dll as expected but when I try to check the page in a browser getting an error message that the 3rd party dlls cannot be found in the mvc/bin directory (and in the other default places). First question if it is normal that the compiler triest to find these dependencies in mvc/bin instead of dll/bin? I mean it's the dll which depends on them.
The other question is that i tried to solve the problem by copy all the dependencies into mvc/packages and set up hintpath in .csproj file but when I execute nuget restore it fetches the 3rd party dlls from nuget repo. How can I tell to nuget that I have these dlls in a directory already? Guess I have to specify in in the .csproj file, but wasn't able to find how.
update:
I'm working with vscode so any right click magic VS does is unrelated here.

Add projects in C# solution which belong to another solution

I have a solution which has a number of projects and each project refers to assemblies that are in a third party folder.
I now need to have access for debugging the code of those assemblies and fortunately I have to code.
I was wondering what the best way is to reference the code of the assemblies in my current solution?
Should I remove all my references to the assemblies (in third party folder) and then add the projects of those assemblies to my current solution or is there a better way? Although this gives me access to the code, the problem I see here is the assemblies were originally in a third party folder so I will need to make sure I have to switch back to the third party folder when I check my code back in.
There must be a better way than this?
You actually just need the corresponding pdb files of the third party DLLs.
The pdb file contains all necessary information. No need to remove the references.
It is not good idea to debug third party assemblies due to licensing restrictions. But if you want to do it, you only can remove references on dll's and add references to projects. You can automate your build to change references to dll's for release builds
You run your project while having reference to 3rdParty folder. Open those library code in seperate visual studio instance and use "attach to process" option in debug menu
Visit http://msdn.microsoft.com/en-us/library/c6wf8e4z(v=vs.100).aspx to know how to do this.
If you have the corresponding *.pdb file to the DLLs in question, you might getting away with just adding them to your solution. They need, of course, to be copied into the same location as their DLL files.

Visual Studio 2010: How refer to a C# .Net class library project with third part dependencies

This is probably a very basic question but I haven't found any detailed information about how project references works in Visual Studio.
I have a Visual Studio 2010 C# solution containing a MainApp project and a C# class library project with third party assemblies inside. When referring to the class library project from the MainApp project, should I just add a project reference or do I need to add references to the third party assemblies within the class library project as well?
In some cases it seems like the third party assemblies are not loaded correctly if I just have the Class Library project reference in my MainApp project although all DLL files (incl third party DLLs) show up in the output folder when building the complete solution.
Edit: I've posted a more specific question since the general answer did not help in my case: How to refer self-contained C# class library project with IronPython inside (Visual Studio 2010)
When using thrid party assemblies/dlls I find it bect to create a folder in a project called "Dependencies" and place them in there, that way they don't get lost or hidden in amongst your source.
Your class library project should reference the thrid party assemblies. You'll need to browse for those (after clicking add reference) and then set the Copy Local property True, that way they will be copied to the directory into which any compiled code is placed.
Your other project just needs to reference your class library project(remember to set the Copy Local property), select it from the Projects list after clicking add reference.
Oh I forgot to add your code files that refer to any publics on the referenced assemblies will require a using statement to link to them.

Where to put my dll files using F#

I have a library with both managed and unmanaged C#, C++ dll files. I want to reference it from F#. Where can I place the C#, C++ dll files? I can not place them in the application folder (I must have copy local = false) and it will be only me who will use the program. I have tried windows/system32, GAC using setup and adding PATH variable pointing to a folder with all the dll files but none of it seems to work.
Thanks for any hint
When building your application in Visual Studio, it looks for the references in all the default folders (depending on your OS, .NET Framework version and other things) but also in locations you specified in the project configuration. Right click on the project in Solution Explorer, click Properties and go to the Reference Paths tab. Add C:\MyDllFolder or anything.
If you do this in all your applications which are using that dll, you could just have it sitting there once.
You can specify dll locations MSDN : Specifying an Assembly's Location or maybe use something like
Assembly.LoadFrom
if you want dynamics.

Team Foundation Server - Add rereference to existing dll to a new class library project

I've just started using Team Foundation Server and have added a new Solution that contains a project of type class library. I need to add a reference to the new class library project to an existing class library (dll) that we have created. What is the best way to do this? I've noticed that if I try to add it from the original location as an existing dll, it keeps the original location of the dll. I think what I want is to actually copy the dll to the new project, and add a reference to it locally - but I can't figure out how to do that.
Write a MSbuild/Nant script that build's and copies the dll to a common lib directory. Then reference the lib\foo.dll in 2nd project. Also create the build order.
Can you include both the old and new projects in the same solution? If so, you can reference the project directly (primary artifact) instead of the .dll output (secondary output). This 'just works' when you need to build multiple configurations, such as debug, release, etc.
If that dll is something that will be shared among different libraries and applications, you may want to consider putting it in the GAC. This will also help avoid versioning issues of putting it in a common lib directory (although you could just put folders in the common lib directory for different versions)
MSDN article on the GAC: http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx
Another way that doesn't involve copying the whole project or messing with the GAC would be to:
Add a reference to the DLL to your project
Open the references folder in your project
Right click the DLL -> Properties
Find Copy Local and set it to "True"

Categories