I have a complex solution which suddenly -- and I mean suddenly, for days it was compiling just fine and the next moment it wasn't -- started complaining about Newtonsoft version compatibilities:
Severity Code Description Project File Line Suppression State
Error CS1705 Assembly 'UploadFramework' with identity
'UploadFramework, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' uses 'Newtonsoft.Json, Version=9.0.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' which has a higher
version than referenced assembly 'Newtonsoft.Json' with identity
'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' UploadProcessor..NET Framework
4.6 C:\Programming\ConnellCampaigns\src\UploadProcessor\batch\EnvelopeSalutationJob.cs 341 Active
I am totally at a loss as to how to fix this...as so far as I can tell, nothing has changed in the code base.
However, I had just done a "reorganize usings" across the entire solution, which modified quite a few files. OTOH, as soon as I ran into this problem, I immediately reverted all the changes -- thank goodness for git! -- so I should be back to where I am.
But I'm not...
Any advice on how to fix this would be greatly appreciated.
Additional Info
I should've mentioned that the project.json file for UploadFramework has this line in it:
"Newtonsoft.Json": "6.0.8"
There's a blue squiggly line under the 6.0.8 which, when you hover the mouse over it, says that the project ended up with version 9.0.1. I don't understand how I can specifically define a particular version, and end up with a more recent one. Perhaps that's a clue as to what's going on.
You have two different versions of the Newtonsoft assembly references in your solution. You can use the "consolidate" option in the nuget package manager and you should be fine.
If it do not work after a revert: clean is the first thing to try, sometimes you also need to clean up the /packages folder - you might have multiple folder for Newtonsoft these. Simply delete the version you are not working. Then the solution should build again.
Related
I am using both ExcelDataReader.Mapping - 2.2.2 and ExcelMapper - 5.2.429 nuget packages in a project. I know it seems redundant, however, one of these projects gives a little more flexibility that I need when reading excel files. It seems there is some conflict between namespaces and classes between these two projects. To fix that, I have ExcelDataReader.Mapping aliased as ExcelReader and ExcelMapper as ExcelWriter. This worked briefly, but now I am running into another issue.
I get the following message on build of the project: warning MSB3243: No way to resolve conflict between "ExcelMapper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=6c3f2bec99465df3" and "ExcelMapper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null". Choosing "ExcelMapper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=6c3f2bec99465df3" arbitrarily.
Using the diagnostic build, I also see this error: Encountered conflict between 'Runtime:C:..\.nuget\packages\exceldatareader.mapping\2.2.2\lib\netstandard2.0\ExcelMapper.dll' and 'Runtime:C:..\.nuget\packages\excelmapper\5.2.429\lib\netstandard2.0\ExcelMapper.dll'. Choosing 'Runtime:C:..\.nuget\packages\excelmapper\5.2.429\lib\netstandard2.0\ExcelMapper.dll' because AssemblyVersion '5.0.0.0' is greater than '1.0.0.0'.
It appears they are using the same name for the .dll file, so it is causing some confusion as to which one it should use. Is there a way to change the .dll file name when installing packages? Or some way to register a full path when referencing the .dll file?
I have started a new Web Application in Visual Studio 2019. I have added a Web Api. Shortly after or at the same time (can't remember), I startet getting warnings like this:
Warning No way to resolve conflict between "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
I noticed but did not do anything as I decided to wait until it gave me problems.
And that is now...
I am about to use a JSon object but when writing this:
JObject jObject = JObject.Parse(result);
The compiler gives me this error:
Error CS0433 The type 'JObject' exists in both 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' and 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
I have searched the web and my conclusions are as follows:
It looks like it is Microsoft.AspNet.WebApi.Client that is the only package installed, that has a dependency on Newtonsoft.Json (>= 6.0.4)
I have installed Newtonsoft.Json (12.0.3)
In Solution Explorer. In reference list, I have only 1 reference. And that is the one for 12.0.3.
In Web.Config I have this entry (and only this for Newtonsoft.Json).
<dependentAssembly><assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/><bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/></dependentAssembly>
In my .csproj I can see 3 different references in 3 different ItemGroups:
One for v. 12.0.0.0
One for v. 12.0.2
And one for v. 12.0.3
I tried to uninstall package Newtonsoft.Json, but is not allowed as other packages are dependent on this.
I have runned this command: Update-Package Newtonsoft.Json in the Package Manager Console, which told me, that no new updates were available.
And now, I have runned out of ideas. I am stucked. Anyone knows what to do?
****New update****
I found the 6.0.0.0. Please have a look at the picture:
Here in resources I double clicked the Newtonsoft.Json reference and in the object browser I can see both 6.0.0.0 and 12.0.0.0.
As you can see, both 6.0.0.0 and 12.0.0.0 are present. 6.0.0.0 is somewhere on my C:-drive inside a SDK.
I have tried to delete the file. My project got nuts. Then I replaced that file with the 12.0.0.0 from my project. This gave me the error that assemplies did not match.
I finally copied the old .dll back. And is a bit stucked again.
Any ideas?
Okay, I fixed it.
I had 2 references in my .csproj file to Newtonsoft.Json. One pointed at packages......\xxx.12.0.3 and one pointing at packages......\xxx.12.0.2.
Both of them was above 6.0.0.0 which was the error I got. So I ignored them.
But acutally, in my project I had only 12.0.3 folder and no 12.0.2 folder. So the reference did not work and VS tried to find another place to look.
I guess it looks around, maybe using the GAC but finally it ended up deep down my local drive in one Azure SDK and found Newtonsoft.Json 6.0.0.0. And that was the problem.
I removed the 12.0.2 reference from my .csproj and finally it worked.
The issue usually comes from two different projects that use different versions of the same library.
Both of those projects are then referenced to another one and the warning effectively warns you that something like this might happen.
Go to the solution and right click - manage nuget packages.
Go to the consolidate tab. Check that newtonsoft is there. If it is, install the same package to all projects.
If that doesn't work, check your projects for added references that don't come from a nuget and remove those too.
In my case, I had to edit the .csproj and look for Newton references. I found out that Antlr3 had a HintPath to an old version. Even the package not existing.
I'm having difficulty using Package Manager to run update-database. Specifically, I'm getting a System.IO.FileNotFoundException
Approximately, the structure of my solution is as follows:
Foo.Data
Foo.Presentation
Foo.Data has all my EF code in. Foo.Presentation is the presentation layer (in this instance, a MVC5 site)
With Foo.Presentation set as the startup project and Foo.Data set as the default project in Package Manager, whenever I try to run update-database I get:
"Could not load file or assembly 'Foo.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified."
If I set Foo.Data as the startup project and the default project I can run update-database (so long as I specify the connection string and provider).
This has been driving me nuts all morning - so if anyone has any ideas, you'll help me get this sorted and preserve what remains of my sanity!
A couple of notes:
I've recently branched the solution. The old branch is working fine
I've checked, double-checked and triple-checked that Foo.Presentation references Foo.Data. It does, and I can access it from Foo.Presentation
Just in case anyone stumbles across this same/similar problem - I was being an idiot.
The cause was a discrepancy in a couple of nuget package versions that were used in both Foo.Data and Foo.Presentation. I had inadvertently used a newer version of the package in Foo.Presentation.
I am having a very odd issue. I have done some research online in regards to this but none of the answers seem to help. This application was compiling and running properly a couple days ago, now it just errors out with the following error. Any suggestions on what I can do to resolve the issue? I really don't know where to go from here.
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=4.0.5.0, Culture=neutral,
PublicKeyToken=xxxxx' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040) File name: 'Newtonsoft.Json,
Version=4.0.5.0, Culture=neutral, PublicKeyToken=xxxxx'
My next steps would be to do the following:
Remove this in all projects using NuGet.
Go into the NuGet package repository and delete the files for Newtonsoft.Json. (they shouldn't still be there but if they are, it indicates a problem with NuGet and more troubleshooting there is required - in my experience, NuGet works about 30% of the time, and the rest of the time it is a pain in the ass).
Manually delete all the bin and obj folders in your project(s).
Re-add the Json library via NuGet.
If that doesn't work, please tell that as well.
I have this exception generated on some user machines (~1 of 20):
Could not load file or assembly 'System, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its
dependencies. The system cannot find the file specified.
I found several references to this error over the web and this site but nothing helped.
I have an add-in application which uses WCF to connect to the server. The add-in built with .NET Framework 3.5 with VS 2008.
The error is reproducible on one of the test machines in only one user account. I install my application and can only reproduce this from one account on this machine everywhere else it is working fine. Furthermore it is only reproducible with only one version of host application which I created add-in for (I assume because it uses differnet .NET Frameworks).
I have checked the fuse logs and I see the following:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
Running under executable C:\Program Files\SolidWorks Corp\SolidWorks\sldworks.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: User = Home\User
LOG: DisplayName = System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/SolidWorks Corp/SolidWorks/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
So by some reasons it is trying to use v2.0.50727\mscorwks.dll loader to load the Version=4.0.0.0 of System.dll. On build machine I'm referring 2.0.0.0 version of System.dll.
I had this same problem - some users could pull from git and everything ran fine. Some would pull and get a very similar exception:
Could not load file or assembly '..., Version=..., Culture=neutral, PublicKeyToken=...' or one of its dependencies. The system cannot find the file specified.
In my particular case it was AjaxMin, so the actual error looked like this but the details don't matter:
Could not load file or assembly 'AjaxMin, Version=4.95.4924.12383, Culture=neutral, PublicKeyToken=21ef50ce11b5d80f' or one of its dependencies. The system cannot find the file specified.
It turned out to be a result of the following actions on a Solution:
NuGet Package Restore was turned on for the Solution.
A Project was added, and a Nuget package was installed into it (AjaxMin in this case).
The Project was moved to different folder in the Solution.
The Nuget package was updated to a newer version.
And slowly but surely this bug started showing up for some users.
The reason was the Solution-level packages/respositories.config kept the old Project reference, and now had a new, second entry for the moved Project. In other words it had this before the reorg:
<repository path="..\Old\packages.config" />
And this after the reorg:
<repository path="..\Old\packages.config" />
<repository path="..\New\packages.config" />
So the first line now refers to a Project that, while on disk, is no longer part of my Solution.
With Nuget Package Restore on, both packages.config files were being read, which each pointed to their own list of Nuget packages and package versions. Until a Nuget package was updated to a newer version however, there weren't any conflicts.
Once a Nuget package was updated, however, only active Projects had their repositories listings updated. NuGet Package Restore chose to download just one version of the library - the first one it encountered in repositories.config, which was the older one. The compiler and IDE proceeded as though it chose the newer one. The result was a run-time exception saying the DLL was missing.
The answer obviously is to delete any lines from this file that referenced Projects that aren't in your Solution.
I got this after downgrading a project from .net 4.5 to .net 3.5.
To resolve I had to go in to the project - properties - settings window and delete all my settings, save the project, exit and restart visual studio, go back into project - properties -settings window and re-enter all my settings and their default values
This worked for me.
Go to Project->Propertied->Target Frawork->Change frame work like 3.5 to 4.0
I had the problem under Linux and I needed to install those. I don't know which one actually fixed the problem, but that error was gone after that:
apt-get install mono-utils mono-runtime-sgen mono-runtime-common \
mono-runtime-boehm mono-runtime-dbg mono-xbuild
I've seen this a couple times, and it is usually fixed by running a repair on .NET Framework (whichever version the application is trying to use).
You are using .net 4? - Maybe on the clients there is only the ".net framework 4 client profile" installed. Try to install full package!!
Download here
In my case, I was able to find issue with ScriptManager by setting Debug=true in web.config file
I answered too late but it has worked in my case.If you are facing this issue in your project please add the following line in your web.config :
<compilation batch="false" >
This worked in my case. If you already have compilation tag in your web.config then add only batch="false" property to it.
You can enable NuGet packages and update you dlls. so that it work.
or you can update the package manually by going through the package manager in your vs if u know which version you require for your solution.
Even I have experience some more strange things, I can see there is no dll in GAC from where the dll is loading but windows > Module shows system.dll version=4.0.0.0 loaded
i just changed my target .net framework and it worked .in my case i changed from .net 4.7 to .net 4.
Right click your solution and select properties
selct properties
Click Application >> Target Framework
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
this is my problem. I installed system.configuration assembly in the project and other class libraries also. now the problem has gone.
am used net 6.0 with aspcore.report and problem like this happened with me
I installed system.configuration assembly in the server project problem solved