I upgraded my RC2 packages to the release packages and am running into an issue with Newtonsoft.json.
I'm targeting the 4.6 framework only, not the cross platform framework (this project has lots of legacy assemblies).
Packages such as Microsoft.Extensions.Configuration.Json in the nuget tool says it needs newtonsoft.json 8.0.3 or higher (8.0.3 worked fine with RC2). However after installation this dependency (and many others) has a chain of dependencies with ends with "NU1012 Dependency conflict. Microsoft.Asp.NetCore.JsonPatch 1.0.0 expected Newtonsoft.Json >= 9.0.1 but got 8.0.3".
9.0.1 won't seem to install in this solution. Looking at that package, it seem to only support .NETStandard, Version 1.3 and not the .NetFramework 4.x
So I'm stuck. The new packages seem to have a dependency on something that doesn't run on the 4.6 framework.
Microsoft.Extension.Configuration.Json depends on Newtonsoft.Json 9.0.1 - https://www.nuget.org/packages/Microsoft.Extensions.Configuration.Json/
Did you update the version of tools from preview1 to preview2? Can you show your project.json?
Yes. Here is my project.json, with the RTE below. Note that the assembly that ends up in win7-x64 is newtonsoft.json 8.0.3.
{
"dependencies": {
"AutoMapper": "5.0.0-beta-1",
"EntityFramework": "6.1.3",
"Microsoft.AspNetCore.Authentication.JwtBearer": "1.0.0",
"Microsoft.AspNetCore.Authorization": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Mvc.ApiExplorer": "1.0.0",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Newtonsoft.Json": "9.0.1",
"NLog.Extensions.Logging": "1.0.0-2016-05-21",
"Swashbuckle": "6.0.0-beta9",
"System.Runtime.Extensions": "4.0.10"
},
"tools": {
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
"version": "1.0.0-preview2-final"
}
},
"frameworks": {
"net461": {
"dependencies": {
"MPP.Api.Auth": {
"target": "project"
},
"MPP.Common.Business": {
"target": "project"
},
"MPP.Common.Data.EF": {
"target": "project"
},
"MPP.Common.PaymentGateway": {
"target": "project"
},
"MPP.Common.Resources": {
"target": "project"
}
},
"frameworkAssemblies": {
"System.Configuration": "4.0.0.0" }
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"xmlDoc": false
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config",
"nlog.config"
]
},
"scripts": {
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
}
}
System.IO.FileLoadException was unhandled by user code
FileName=Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
FusionLog==== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///P:/MyCoreProject/nxt/wallet/wallet/src/wallet/bin/Debug/net461/win7-x64/
LOG: Initial PrivatePath = NULL
Calling assembly : Microsoft.Extensions.Configuration.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: P:\MyCoreProject\nxt\wallet\wallet\src\wallet\bin\Debug\net461\win7-x64\wallet.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///P:/MyCoreProject/nxt/wallet/wallet/src/wallet/bin/Debug/net461/win7-x64/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
HResult=-2146234304
Message=Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=Microsoft.Extensions.Configuration.Json
StackTrace:
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
at wallet.Startup..ctor(IHostingEnvironment env) in P:\MyCoreProject\nxt\wallet\wallet\src\wallet\Startup.cs:line 41
InnerException:
What's what sometimes seems very confusing to me, but my read of the newtonsoft.json package 9.0.1 dependencies section reads "no soup for you" on the full framework.
That means it has no dependencies on that target framework
The first thing I found is that you depend on a version of NLog.Extensions.Logging that depends on RC2 version of ASP.NET Core. As a result you end up mixing 1.0.0 and RC2 packages. I can see that the 1.0.0-rtm-alpha1 version which depends on 1.0.0 packages is now available (https://www.nuget.org/packages/NLog.Extensions.Logging/1.0.0-rtm-alpha1). I was able to restore the project successfully after I moved to this version.
I am not sure why you need a reference to System.Runtime.Extensions and/or if the version you have is correct. With the version you provided I received a lot of downgrade warnings:
warn : Detected package downgrade: System.Runtime.Extensions from 4.1.0 to 4.0.10
warn : test (>= 1.0.0) -> Microsoft.AspNetCore.Mvc (>= 1.0.0) -> Microsoft.AspNetCore.Mvc.ViewFeatures (>= 1.0.0) -> Microsoft.AspNetCore.Mvc.Core (>= 1.0.0) -> Microsoft.AspNetCore.Mvc.Abstractions (>= 1.0.0) -> Microsoft.Net.Http.Headers (>= 1.0.0) -> System.Runtime.Extensions (>= 4.1.0)
Note I commented out your project references otherwise I was not able to restore anything. You need to make sure that these project don't bring RC2 packages.
I upgraded NLog but i'm still getting 8.0.3 in my output. The other dependencies are plain old .net 4.5 libraries. Some of them do reference 8.0.3. New and improved DLL hell.
I can only assume this is being brought by one of your project references (i.e. Mpp* projects). I did not see any restore errors nor Newtonsoft.Json 8.0.3 in my project.lock.json after I moved NLog.Extensions.Logging to the rtm version.
I updated it on one (of several) projects and it's working. Other projects still reference 8.0.3. Very strange. I also removed swagger for now. I imagine things will settle down as people catch up to RTM. Thanks for the pointers.
I had issues with Newtonsoft.Json both on my development and Azure kudu deployment. Manually deleting bin/ folder solved the issue for me (I also had to delete repository folder on Azure). Could you try this? It might work for your case too.
I gave that a shot but it didn't help. I also need to find a way to bend nuget to my will - packages go where I tell them to go - and don't check them in!
Is there not a means in .NET Core to (like win Web/App.config) to specify a forced version upgrade via the configuration/runtime/assemblyBinding/dependentAssembly/bindingRedirect
tag?
@h3smith - are you trying to version of a package higher than the one referenced by your dependencies? If so, add it to your project.json. Restore should bring that version in and take care of wiring up redirects for you.
Had the same issue. Even after revert to RC2.
This helped as I remember
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
},
Looks like if you use some library that was built with RC2 you won't be able to run with some strange errors.
Adding to this that in RC2 MS Extensions used internally two different versions of Newtonsoft. Better to abandon RC2 altogether. Upgrading to RTM and Newtonsoft 9 cured my JSON problems.
I think, that sort nuget packages by folder with different versions was better idea, than we see now
I had the same issue, because of Newtonsoft reference in a dependency library, after upgrading to the latest version of Newtonsoft, the problem resovled.
The people that are having problems, do you have a csproj involved?
David, I have strong example to reproduce this issue
1) Create ASP.NET Core project
2) Try to add "tweetsharp": "2.3.1" package. It's ok and when you open tweetsharp dependencies - you see Newtonsoft 9.0.1. Ok
3) Create .NET Core library and retarget it to net46
4) Add package "tweetsharp": "2.3.1" to this lib. In dependencies - you see Newtonsoft 5.6.0 (not 9.0.1)
5) Add this library to references in ASP.NET project. Try to run it - and you catch exception in this line of code
Configuration = builder.Build();
I'm hitting an issue with NewtonSoft 9.0.1 as well, no csproj involved.
VS2015 Update 3: File -> New Project -> ASP.Net Core Web Application -> Web API
And then I added "NewtonSoft.Json": "9.0.1" to the project.json file.
Now there seems to be a conflict with Microsoft.AspNetCore.Mvc and Microsoft.Extensions.Configuration.Json that both state:
_"The dependency Newtonsoft.Json >= 9.0.1 could not be resolved."_
The VS-solution-files are found in the attachment.
CoreWebApp.zip
Added: A colleague was able to resolve this solution. Seems like my machine has some leftovers from RC1 or RC2. I will cleanup and try again.
Result: I uninstalled "Microsoft .NET Core 1.0.0 RC2 - SDK Preview 1" and also added "NewtonSoft.Json" by using the Nuget Package Manager, instead of editing the project.json file.
Everything is now resolving like it should.
(So once you move one project/solution from RC2 to RTM, you have to move all projects. RC2 and RTM cannot live together on a single machine. Not a bad thing, but important to be aware of.)
Please, no binding redirects anymore! keep .net core clear!
Need "packages" folder with different packages versions, like RC1
Stop sending me emails
On July 3, 2016, at 05:32, Artemov Ivan [email protected] wrote:
David! I have strong example to reproduce this issue
1) Create ASP.NET Core project
2) Try to add "tweetsharp": "2.3.1" package. It's ok andw when you open tweetsharp dependencies - you see Newtonsoft 9.0.1. Ok
3) Create .NET Core library and retarget it to net46
4) Add package "tweetsharp": "2.3.1" to this lib. In dependencies - you see not Newtonsoft 5.6.0 (not 9.0.1)
5) Add this library to references in ASP.NET project. Try to run it - and you catch exception
Configuration = builder.Build();
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/aspnet/Home/issues/1609#issuecomment-230146408
I got a similar issue.
I am having a Class Library (.xproj) with some shared models (Contracts) and reference the "Microsoft.AspNetCore.Mvc.DataAnnotations": "1.0.0"
there, which also indirectly refers to Newton.Json 9.0.1. It targets both, netstandard1.6
and net46
(I can't reference netstandard1.6 in net46 apps and I can't add Microsoft.AppNetCore.Mvc.DataAnnotations in netstandard1.4).
I also have another project, a Consolle Application, targeting net46 where I want to run Orleankka with Azure Table Storage. So I reference WindowsAzure.Storage": "7.1.2"
in the consolle application.
WindowsAzure.Storage depends on Newtonsoft.Json 7.0.1. The packages restore correctly, but when I run the project, it crashes with an exception:
Microsoft.WindowsAzure.Storage.StorageException was unhandled
HResult=-2146233088
Message=Die Datei oder Assembly "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" oder eine Abh盲ngigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis 眉berein. (Ausnahme von HRESULT: 0x80131040)
Source=Microsoft.WindowsAzure.Storage
Which basically says it can't find the Newtonsoft.Json assembly. There is one in the folder with the exe file, but it's 9.0.1.
Since we can't load both versions, I'd like to know if there is a way to tell it to use hte 9.0.1 instead like bindingRedirect used to work
Should I open a new issue for this?
If yes, i would rather post it into the .net core repo
I had same issue. Resolved as follows.
dave
I'm facing the similar issue in my Universal Windows project that is built under JavaScript (WinJS). I have a Universal Windows Rutime Component which has some method. It gives error while calling a native method in Runtime Component which has JsonConvert desrialization.
An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll but was not handled in user code.
Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Detail information about my issue is here: https://social.msdn.microsoft.com/Forums/en-US/348ba396-e28a-4b89-8c19-9a0a31639f1d/uwp-winjs-windows-runtime-component-could-not-load-file-or-assembly-newtonsoftjson?forum=wpdevelop
Any solution / work-around for this issue?
Newtonsoft.JSON itself is compatible with .NET Core 1.0
Hi @Legends , I understand it supports Newtonsoft.Json. But in my case it seems there might be some bug. I tried so many times creating fresh project (Universal Windows Project under JavaScript (WinJS) with Universal Windows Runtime Component) and installing latest Newtonsoft package but gives the same error again and again. Whereas there is no any error and runs well in Windows 8.1 WinJS project with Windows Runtime Component (Windows 8.1).
Thank you!
@olikishor , I had the FileNotFound exception too. I solved this problem as explained here. I got the tip from the dotnet/cli team. Perhaps you have the sam issue, don't know... you can take a look at the link
as per @davidames it was solved by my other projects upgrade to 9.0.1, then afterwards in the same way other dependencies have to match to the the project references. Any upgrade on packages will fail either loading the project on the Build configuration, or later on when trying to resolve an instance
This issue is being closed because it has not been updated in 3 months.
We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.
I had a same problem in .NetCore 2.2.
I deleted from references Microsoft.Extensions.Configuration.Json and installed from Nuget new Newtonsoft.Json (12.0.3- beta) nuget pacgage.
That fixed this issue.
Most helpful comment
I had same issue. Resolved as follows.
dave