How do I install a C# class library in Visual Studio? - c#

I am trying to use a class library which I found on a different question here.
I am quite new to C#, Visual Studio, and OOP in general, so please excuse me if this is not the right question.
I followed the link and downloaded the zip. The help file does not seem to contain any directions on how to get Visual Studio to utilize the library. I figure that I have to tell it to use the library somehow, but I really don't know what to do. Or maybe I need to copy the .dll to a specific folder. I also assume I need using ... in the top of the .cs files that use it.
How can I use this library in a Visual Studio C# project?

You should add a reference.
In the project you are working on, you can add a reference to the dll (or a library) by doing navigating to:
(Project)->References->Add Reference
[You will find Properties, References and [class]files below your project]
According to your question, you should add "UltraID3Lib.dll" to your project references and use it through adding a using on top of your project files like this:
using HundredMilesSoftware.UltraID3Lib;
After you have successfully added the resource you should build the project and it will copy all the necessary files to your output directory (bin/Release or bin/Debug).

Step 1:
Open Debug Folder (you can find it In your project Folder => Bin => Debug). Copy .dll >files there.
Step2:
In Solution Explorer Right Click on References => Add References
Go to Project Tab.
Under the Project Tab you can find Added References (References added In Debug Folder). >Simply select needed references & hit OK. You're done
Happy Coding....! :D

Related

Shared Projects list empty when adding reference in VS2019

I am using VS2019 Community Edition and have created a C# Console App solution in one instance of VS2019 and a C# Shared Project in another.
I have added a class to the Shared Project and then want to reference this shared project in the other project, so I right-click the References and choose to Add reference, then choose Shared Projects. The resulting window shows an empty list. Am I doing something wrong?
Other questions I have found suggest that the wrong Shared Project was created, i.e. using the wrong language, but I have checked and mine are indeed both C# projects.
The other suggested methods were to add it to the project manually by editing the .csproj file, which didn't work either, or something to do with MS Build config which is more than I want to get involved with.
Is it me or VS2019?
UPDATE 1:
So I managed to kind of fudge it, buy adding the Shared Project to the same project as the console project, but storing it in a different folder and reusing the .sln solution file to load it as a solution in VS2019. Progress, but even though I can add it as a reference, it doesn't seem to know about the classes in the Shared Project, even with a using reference.

Add Dynamics GP namespaces Visual Studio project

I need to add the following namespaces
• Microsoft.Dynamics.Common
• Microsoft.Dynamics.Common.Types
• Microsoft.Dynamics.GP.BusinessLogic
• Microsoft.Dynamics.Common
• Microsoft.Dynamics.GP
to my project in Visual Studio,
Kindly suggest how I can do so.
First you need to add references to the libraries to your project. Right click the project name and select "Add Reference" or if the project shows a references folder right click that and choose to add. If the library doesn't show in the list then browse to where ever it is located and select it.
Then at the top of the file add a using command. For example:
using Microsoft.Dynamics.Common;
Please feel free to post additional questions.
Either Download and install the SDK on your machine, It will include the dlls needed to integrate with dynamics or copy the dlls from where ever you have them. (make sure you get the correct version for GP). From there you should create a folder in your project to hold the files in one place and copy them there. Once you have the library files you add references to the files by going to the browse sections of the reference manager and then browsing to the where you copied the files. (Quick note. make sure that you set copy local to true so that it will include the files locally when running and not look for them in the GAC). Once referenced you should be able to access the namespaces and include them with using keyword as needed.
If in case you are not getting the required dlls even after installing SDK, then add required Nugets online in visual studio(and later). After that you can start using the keyword "using" in your VS project.

Using Namespaces in Other Projects

As the screenshot demonstrates, I have a project SampleApp that uses the namespaces EDAM and Thrift. I want to replicate the functionalities of SampleApp to another project.
Do I have to include the two projects (EDAM and Thrift) in my other project? Can I just copy the folders instead of including the actual project files? Can I just convert them to some sort of DLL or something?
You definitely should add references to the EDAM and Thrift projects from the SampleApp project.
To do so, follow these steps:
Right click the 'References' folder in the SampleApp project.
Select 'Add Reference...'
On the popup, go to the 'Solution' tab.
Select the EDAM and Thrift projects.
Under no circumstances should you just copy the files.
Don't copy the folders, just add references to the projects. Even if the projects are class libraries you don't want to copy the DLLs, instead you should add references, just in case your DLLs are updated:
How to: Add or Remove References in Visual Studio
If the "other" project is in the same Solution, you should be able to reference EDAM, Thrift and even SampleApp from that project much in the same way you set the references up for SampleApp.
If this "other" project will be in a new solution...I'd have to do a little research and testing.
Visual Studio project references are equivalent to referencing an assembly directly, but it has a great advantage: when you build a project, Visual Studio take cares of building its dependent projects too.
In addition, Visual Studio will prevent circular references.
There're many other pros, but it's a good summary.
Copy-pasting the code files isn't importing a namespace: this is duplicating code! And referencing the assemblies directly is a waste of time and features!

VisualStudio doesn't recognize a new reference that I add

I have written a DLL and then in my solution I am adding a reference to it, but when I declare it in the usings section, it gives me error that this is not recognized, are you missing a reference?
here is how I set up my solution...
1- First I had created my DLL. Let's name it MyDLLLibrary, sitting somewhere on hard drive.
2- I also had a solution, consisting of several other projects...for all of these I have created a folder like "C:\_debug" and I have set "Output Path" and "Reference Path" of all these projects to point to that common folder. So far, s good.
3- Now I add that MyDLLLibrary to this solution, change its "Output" and Reference Path to point to the same common debug folder, use Add Refrence and at the reference to MyDLLLibrary to the project I want in the solution and rebuild the solution...
Now if I use a using statement, still it doesn't recognize it.
I even tried the add refrence from projects tab..that didn't work either.
Check the project properties of both assemblies and make sure that the framework setting for both is .NET Framework 4 and not .NET 4.0 Client Profile or something else.
While using Visual Studio 2017, I had to close visual studio and delete the .vs folder (at the root of the solution). This fixed my issues

open a .csproj with monodevelop

I've downloaded a framework with samples in .csproj project format.
How can I open them in MonoDevelop?
I'm interested in using some classes in that framework.
It has a folder structure like: Accord.Statistics.Models and a main folder Accord with a subfolder Statistics with a subfolder Models with a file ModelFoo.cs
I want to use that file (that begin with
namespace Accord.Statistics.Models
) in a MonoDevelop Solution under Ubuntu.
If I copy the folder or single files inside my new Solution I get the error
Are you missing a using directive or an assembly reference?
How can I do?
Create a new empty solution, copy your projects and their sources into the solution folder, then right click on the solution in the solution explorer
("View" → "Pads" → "Solution") and choose "Add" → "Add Existing Project".
Rather than opening the VS project file, you may be better off making a MonoDevelop project file and adding the code files and references necessary (typically Accord.dll, Accord.Statistics.dll, or something along those lines) to your new project. That is, of course, if MonoDevelop doesn't have an import function.
Generally, the "missing using or reference" error comes when you use a symbol defined outside of the current project. If you're actually using something from another assembly, you need to add it as a reference to the project, so the metadata is imported and used to link. If it's from the same project, you may need to import the namespace with a using Accord.Statistics.Models statement.
First of all, I would use a separate solution file for MonoDevelop because MD sometimes puts slightly different settings in there. The same applies to .csproj files, so if you want your project compilable with both VS and MD, watch out that you don't commit any project file changes that don't work in VS.
Regarding your problem: Remove the references using MD and re-add them. MD adds references in a way that they're compatible with both VS/MD (my experience).

Categories