using Newtonsoft.Json in c# not working even after downloading package - c#

I downloaded Newtonsoft.Json.11.0.2 package by package manager console,
and it certainly showed that the package is installed in project.
However, when I try to use the package
using Newtonsoft.Json
visual studio keeps warning me the name is not found and draws red underline.
What should I do? uninstalling and reinstalling the package didn't work.

Make sure you have selected same project while installing package

Add a reference by clicking on your project in the solution explorer with right click -> References -> Newtonsoft Json.
Add it and compile.

Had the same issue, i notice that i have some bll files that have been installed
Microsoft.AspNetCore.Mvc.NewtonsoftJson
Newtonsoft.Json
Newtonsoft.Json.b..
i removed all the files exept 'Newtonsoft.Json' closed the vs.code reopened it and it worked!

Related

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

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

The project references NuGet packages that are not on this computer

i'm getting following error when i build my solution in visual studio 2015.
but when i try to add that particular package then visual studio show it already added
Did you notice something? the version is different you need version 1.0.5 instead of 1.0.7
Open Nuget Package Manager and pick "Unistall" on this package, than istall it again. If this does not help you do next:
Unload project and remove all reference on this package from .csproj file
Remove reference on this package from Web.config (or App.config) if it there.
Remove reference from packages.config file
Install via nuget you package again.
Hope this helps you.
Right click solution in visual studio and select "Restore Nuget Packages", it will download the missing packages
Use the following command in the Package Manage Console:
Update-Package -reinstall -Project YourProjectName
It is by project, but this way is garanteed it works, at least in 100% of cases that happen to me.

NuGet package files missing

I am making a program in C# WPF with the mvvm-light NuGet package. It worked well for some time but now I get errors on InitializeComponent() of my MainwWindow. When I try to debug, I get deeper and deeper in the program until it says:
"ViewModelBase.cs not found"
ViewModelBase.cs is a file in the NugetPackage of the mvvm-ligth library.
Does anyone know how this is possible/solved?
If you are sure that you correctly added package: Right click on solution -> Restore nuGet packages.
If you are not sure: Right click on solution -> Manage nuGet packages for solution -> Select MvvmLight package and check that package has been installed for the project which is throwing that error (checkbox for that project should be ticked).

'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.

Error 22 The "EnsureBindingRedirects" task could not be loaded from the assembly

I cloned a project with vs 2013. When I run it I get this error.
Error 1 The "EnsureBindingRedirects" task could not be loaded from the assembly D:\BMaster\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.Tasks.dll. Could not load file or assembly 'file:///D:\BMaster\packages\Microsoft.Bcl.Build.1.0.13\tools\Microsoft.Bcl.Build.Tasks.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. BargainMaster.Web
I'm not sure about root cause of this issue but it appeared when I added missing libraries by hand.
I resolved it by doing this:
Delete <solution>\packages\Microsoft.Bcl.Build.1.0.13\
Close solution
Open solution
Navigate to View / Other Windows / Package Manager Console
Press Restore Packages in right top corner of the window
Re-build
(For some reason none of the other answers worked for me.)
I resolved the issue by doing this:
Delete the "packages" folder.
Right click on the solution > Manage NuGet Packages or Solution.
Downgrade Microsoft.Bcl.Build to a previous version 1.0.14. (Latest stable version at the moment of writing this is 1.0.21)
Restore packages and rebuild.
I just went to the Manage NuGet packages options for the particular VS project and updated the version of the Microsoft BCL nuget and it solved the problem for me.
Verify that you have Nuget Package Manager installed.
By default, Visual Studio 2010 doesn't have it (later versions do)
- Open Tools / Extension Manager
- Search for Nuget Package Manager and click Download
- After this I had to remove the Nuget package (Microsoft.Bxl.Async, Microsoft.BCL, and Microsoft.Bcl.Build) causing the error, restart VS and re-add the package.
The above answer didn't work for me. I just had to remove references (in packages and proj file) to Microsoft.Bcl.Build.. Rebuilt and succeeded.

Categories

Resources