I am making a C# Web Form application and I want to use RedditSharp. https://github.com/SirCmpwn/RedditSharp
I've never used an API in C#, this would be my first time using something outside of the C# generics. Could someone help me understand how to import it to use it?
Create C# Web Forms project in Visual Studio
Download RedditSharp code from Github
Compile RedditSharp into DLL (build enclosed solution, grab DLL from the bin/release folder or wherever it builds to)
Add a reference from your project to RedditSharp DLL
Check examples at https://github.com/SirCmpwn/RedditSharp, add something like that to your code
Don't forget to add "using RedditSharp;" to the top of your code file.
Easiest thing to do in Visual Studio is to install the nuget package. Go to Tools...Nuget Package manager... Manage Packages for Solution. Search for RedditSharp, click install.
Now you can reference it from anywhere in your project by adding:
using RedditSharp;
This has the added benefit of Visual Studio alerting you to new updates anytime the official RedditSharp project is updated.
Related
I have found the FTPFactory Code Project, and I want to test drive it. However, so far I only installed new packages via Nuget. How do I add FTPFactory to my Solution in Visual Studio 2015?
You have 2 options.
Since this is such a simple single class library, you could just manually copy the ftp.cs file from the source and add it to your project.
Alternately, you can download and build the project which will produce a FTPTest.dll file. You can add a reference (browse) to this file in your project and use the class form there.
I previously asked a similar question regarding Visual Studio 2013 but now I'm running into the same problem with Visual Studio 2015 but it seems to work differently, which makes the previous answer not applicable to this question. This is my previous question: Visual Studio 2013 - How to debug a project within a solution
I'm attempting to add a project reference. I have a library I'm working on in a separate solution/project and a console application I want to use to test and debug the library.
I tried: Add Reference > Projects > Solution > Browse
But the open file dialog does not contain .sln files in the filter list and if I force it to display them by typing *.sln and then select the Solution I get:
"Please make sure the file is accessible and that it is a valid assembly or COM component."
What am I doing wrong? How do I properly add a Solution/Project reference?
For me issue was due to difference in Target framework. One was .NET Framework 4.5 and other was .NET Framework 4.5.2
Verify if the Target framework is same for your project and the project reference that you are trying add reference.
(Right click on project -> properties -> Application Tab(Target frame work))
Right click on your solution file in Solution Explorer window, click Add and select Existing Project...
Once the project is a part of the solution, you will be able to add project reference.
In case anyone else runs into this here is something that I found. I had almost the exact same issue in VS 2015. I created a console app and then a class library project but could not add a reference to the class library.
It turns out I didn't create a class library project as I had thought, but rather a class library (package) project. These are different things and I was unaware of what the (package) part meant when I selected it. This is for creating Nuget packages, apparently.
I'm not sure if this is something new to VS 2015 but I had not run across it before and it caused me some grief. The error message ('A reference to ClassLibrary1 could not be added') was totally worthless in trying to debug it.
You should add project to your solution first; after adding project to your solution, you can reference it.
To add an existing project to your solution:
Add reference menu:
Add references dialog:
In order to add a project reference, the project has to be part of the solution.
For me issue was due to a difference in the types of projects. One was a C# Windows forms project and the other project was a C# Universal Windows project.
The Windows Forms project couldn't reference the Universal Windows project. The error was "Unable to add a reference to project "XYZ".
It appears you can have a library shared between both types of projects by folloing this answer: What kind of class library works with both Universal and Winform projects?
I ended up having a different solution. I had three projects in the solution which referenced a NuGet package which was no longer available. I had the library locally but I was unable to add it. I found that because of the BUILD ORDER and DEPENDENCY of my projects, I had to add it to the project that was built first, then I could add it to the projects that were dependent on that project.
I had this problem today and I looked at the configuration manager for the solution. The projects had different platform settings. I made them both Any CPU and rebuilt. Then I could reference the project.
I come from a long Java background and very new to C#. I was trying to run one of the starter kit applications from Windows phone and I am getting this error.
A first chance exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.WindowsPhone.dll
I am finding it hard to debug this because I am directly referring to the dll file under References pointing to Newtonsoft.Json.WindowsPhone. In Java, I would have searched for the library and downloaded the source to step into the exact location during debugging.
If that is possible, how would I do it in C# (as in how would i refer the library source for my project to pick up at run-time)? I am using the Visual studio 2010 Express Edition as the IDE.
Download the third party library you are dealing with
Add this library's project into your solution
In your project, remove the reference to the 3rd party library
Add a project dependency into your project, make it depend on the 3rd party library project you have just added to your solution
Compile and run, happy debugging
My best guess is you should download last release of Json.NET, remove the compiled library from your project's references and add reference to the source code project. (Add Reference... > Projects > Browse...)
Once you have stopped your program in the debugger, you can use the modules window to load the symbols for Json.NET. Obviously, you need to have the symbols on your machine so you can browse to them.
Failing that, you can switch to a project reference and include Json.NET in your solution as Dan suggested.
The easiest way is to download their latest build then inside visual studio right click your solution and under add menu select existing project point to project file of the library and click open button. after that u will be able to set brakepoint wherever u want.
I would like to use log4j.net in my windows forms project. However I have never used any library or dll in .NET. How to do it? I look at the site, but I can't find it.
I'm using visual studio 2010.
Add the log4net assembly to your project:
Browse to the log4net downloads page and download the latest log4net archive
(right now the latest version is 1.2.10).
Extract that archive and place the files somewhere to your project
(for example in a folder like yourproject/lib/log4net).
In Visual Studio right click in your project on the References folder and click on Add Reference....
Browse to the folder where your assemblies are (see point 3) and choose the log4net.dll assembly.
Here are some nice basic tutorial for the first steps using Log4Net:
Log4Net Tutorial pt 1: Getting Started
Using Log4Net in 4 Simple Steps
Log error or exception using Log4Net
In your project, you need add a reference to the library, usually by selecting the DLL from the references dialog.
A package manager, NuGet, has been created as an add on to Visual Studio 2010, which lets you select libraries - it will download and set them up for you.
Whichever way you do this, you will now be able to use the library - in a code file, use the using directive to import the namespace, then you can use the classes and other public members of the library in your code (though you could use the fully qualified name every time, if you wish to).
This has nothing to do with a library being open source or not, by the way.
you can easily get now using NuGet package manager in visual studio 2010
Write this command in Package manager console.
Install-Package log4net
See this link
Do you have any specific problems?
Check link below and maybe ask a question if you are stuck on something:
http://sadi02.wordpress.com/2008/06/29/log4net-tutorial-in-c-net-how-can-i-show-log-in-a-file/
Hey everyone, I'm currently having difficulty adding the latest taglib-sharp solution to my current solution which contains my vb.net console project on Visual Studios 2010. Essentially I want to code everything necessary in vb and use taglib-sharp to extract all tags needed from an mp3 file. Unfortunately, when I include the solution of taglib-sharp and perform the necessary conversion visual studios 2008 to 2010, I receive an error stating "Failed to backup file as C:\temp\taglib-sharp-2.0.3.7-windows\taglib-sharp-2.0.3.7-windows\Backup1\taglib-sharp.snk". I made an attempt to build the solution with no luck. How do I resolve this?
To be quite frank I'm not sure if I need to open the solution if I just want to use the libraries for my vb program. Do I need the solution in order to use for instance "TagLib.File"?
In case you're wondering, I downloaded this library from http://download.banshee.fm/taglib-sharp/2.0.3.7/
I would recommend installing taglib-sharp with NuGet. NuGet is the best and easiest way to use opensource libraries in Visual Studio. You dont have to compile anything, and you don't need to think about projects and solutionfiles.
To install TagLib#, run the following command in the Package Manager Console in Visual Studio.
PM> Install-Package taglib
The NuGet distribution of taglib-sharp can be found at http://nuget.org/packages/taglib. The official source code repository is at https://github.com/mono/taglib-sharp.
Either ignore the backup, or open TagLibSharp in 2008, compile the DLL and then reference it in your 2010 project if you only need to use the libraries.