How do I install Newtonsoft.json for Visual Studio 2010? - c#

I am trying to make Newtonsoft.json available for use in my local Visual Studio 2010 projects. I installed NuGet.Tools on my system. Now I see an item in the Solution Explorer called Service References that wasn't there before, but I don't understand how to use that to reference the Newtonsoft package I also downloaded, which is currently in my Downloads folder. Do I need to move the package to a different location to reference it?
Thanks for your help.

You can right click on the project where you want to install newtonsoft nuget package.
You will find an option "Manage NuGet packages".
Then search online for "newtonsoft".
This would add a packages.config file in your project (depending on which framework you are targeting to ).
this new file contains all the nuget dependencies required for this project.
Refer this blog for more details

VS2010 is old and is unable to update to the latest NuGet version. This means that adding recent packages will often fail; however, you can often add an older version of a package that has a compatible NuGet version and it will work. This causes the suggested answer by #ManojChoudhari to fail for me. In the case of Newtonsoft.Json, the following worked using the Package Manager Console:
Install-Package Newtonsoft.Json -Version 9.0.1

Related

Can a package contain a package?

Installing Packages from Nuget are one of the most efficient ways for developing C# applications. It's a huge time saver.
However, can a Package I install from Nuget also contain a package(s) installed within it? If so how can I view sub-packages within a Package?
Short answer is yes, you can use packages inside of other packages. They are called dependencies, and the other packages will get installed along side the first package. Here's the Microsoft Documentation on nuget package dependency.
EDIT:
Here's how to view/manage these in visual studio. You can view all other packages in the dependencies section shown below. This package depends on System.ValueTuple with a version of 4.5.0 or greater.

Emgu error when trying to install emgu.CV.runtime.windows in VC# 2017

I'm trying to install emgu.CV.runtime.windows from within Visual Studio 2017, and installing by the recommeded method of right-clicking references and installing via NuGet.
However I am getting the error below.
Could not install package 'Emgu.runtime.windows.msvc.rt.x64 19.28.29336'. You are trying to install this package into a project that targets .NETFramework,Version=v4.7.2, but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
According to the package information, its dependencies are
enter code here.NetStandardVersion=2.0
enter code here.Engu.CV (> 4.5.1 && < 4.5.2)
enter code here.Engu.runtime.windows.msvc.rt.x86 (= 19.28.29336)
enter code here.Engu.runtime.windows.msvc.rt.x64 (= 19.28.29336)
I checked and c:\windows\Microsoft.NET\Framework contains a folder for v2.0.50727, so it seem .net 2.0 is installed (as is v3.0, v3.5, v4.0.30319)
I have emgu.CV 4.5.1.4349 installed.
I need this library so that I can have the enter code herebitmap.ToImage<Bgr, byte>(); function.
Why am I getting this error?
Any help would be greatly appreciated.
The solution is migrating from package.config to package references for every project you have. Simply right click on package.config and click "migrate package.config to PackageReference".
Then, install the runtime package again and it will work.
For the new Emgu Nuget package you do need to use PackageReference instead of the traditional package.config.
What worked for me on Visual Studio 2017:
Uninstall all NuGet Packages [This removes the package.config file]
Go to Tools --> Options --> NuGet Package Manager --> General
Change the default package management format to "PackageReference"
Check "allow format selection on first package install"
Click OK
Install Emgu.CV, Emgu.CV.Bitmap, Emgu.CV.UI and Emgu.CV.runtime.windows
These Emgu packages should now appear under your references and you should not see a package.config file.
Nuget Options Image
I encountered the same error. I don't know why we're getting it, but I was able to find a workaround.
Visit the nuget page for the package.
Click "Download Package" to download the nuget package directly.
Open the downloaded file using your archive utility of choice and navigate to the "\runtimes\win-x64\native" folder.
Copy both dll files into the output directory of your project.
After doing this, my code executed without error. Make sure to install emgu.CV.Bitmap as well.
I changed my projects Target Framework to ".NET Framework 4.6" and then went to "Manage NuGet Packages", selected "Browse", typed in "emgu.cv.runtime" then installed version 4.5.1.4349 and it worked.
Here is how I solved it,
1- downgrade .Net framework to 4.6 from project properties
2- Uninstall Emgu.CV and related ones (you will see which ones needed to be uninstalled in Errors List)
3- Install Emgu.CV.runtime.windows from Solution Nuget Manager ( it should install fine now)
3- upgrade .Net framework to 4.8
4- install Emgu.CV 4.5.1 (latest)
5- install Emgu.CV.UI 4.5.1 (Emgu.CV.Bitmwp was installed automatically for me)
and that's it, now you can use bitmap.ToImage<Bgr,Byte>(), note that the Image<Bgr,byte>(bitmap) doesn't work anymore.

Package requires NuGet client version ... or above

After I download my project from GitHub and try to compile it I am running into the issue of "package requires NuGet client version ... or above" but I am using Visual Studio 2017 with the latest NuGet version for that version. The issue is fixed after building the package twice but is there a way that I could stop this from happening in the first place and have it so that these issues go away after the first compilation of the code?
I had a similar problem while adding NUnit via Nugget Manager. Instead of adding the package via Nuget Manager, I downloaded the framework's dll files from their website and add them as a reference to the project.
If you still want to use the NuGet manager, you have to upgrade to a newer version of Visual Studio

Cannot find Math.net in References after installing package with NuGet in Visual Studio 2015

I'm trying to use the Math.net extension for Visual Studio 2015 with C#.
Unfortunately, after installing the package with
PM> Install-Package MathNet.Numerics -Version 3.20.0
I cannot find it anywhere in the Add References menu. I searched Assemblies->Framework and Assemblies->Extensions and COM, but it's not there
I wouldn't mind the just adding the DLL to my project, but I cannot find the DLL anywhere on https://numerics.mathdotnet.com , all the links take me to the NuGet package manager.
Also, do I need to distribute the MathNet dll with my application if I add it through the package manager, or does it build internally with the application?
Sorry, new to .net library management
I see that when I ran the command line, it added a packages folder to my project folder. Which has a few different versions of the library per .net version. Which I could browse to with Add Reference->Browse->Browse
Is this the correct way about adding a third party library?

'Newtonsoft' could not be found

I pasted the code from http://www.codeproject.com/Tips/789481/Bridging-the-Gap-between-Linqpad-and-Visual-Studio into Visual Studio 15. It tells me that 'Newtonsoft' could not be found. I open the folder "\Microsoft Visual Studio 14.0\Common7\IDE\PrivateAssemblies" and found that the file Newtonsolft.Json.dll is already there. Could anyone tell me how to fixed problem?
Solution Explorer->Right Click on Project Name -> Click on Manage Nuget Packages -> Search for newtonsoft -> Click on install button
Go to Tools -> Library Package Manager -> Package Manager Console
and in the console just write Install-Package Newtonsoft.Json -Version 9.0.1
For me I had the package already installed but it was missing the references and it could not be added.
Helped me: in NuGet Package Manager to downgrade and upgrade Newtonsoft.Json
You have to get the correct NuGet package. From your link:
You can open the NuGet package manager in: Tools -> Nuget Packet Manager -> Manage Nuget Packages for Solution..
I had a similar problem and Google API's had a dependency on Newtonsoft.Json, not allowing me to uninstall Newtonsoft.Json and trying to reinstall.
Removing and and reinstalling Newtonsoft.Json will likely solve the problem, but in my situation, I had to go into Nuget Package Manager -> find Newtonsoft.Json -> select Options dropdown -> check "Force uninstall even if there are dependencies on it".
Checking that box allowed me to remove and subsequently reinstall Newtonsoft and the solution properly referenced it after.
I had the same problem with visual studio 2019. Simply restarting visual studio fixed the issue.
After restarting, the References list in Solution Explorer did show the "Newtonsoft.json".
Right click on the client project side and select Manage NuGet packages.
Then search for Newtonsoft.Json on browse and install.
If the class you are trying to use Newtonsoft is in client you must install the package for the client.

Categories

Resources