How to solve the Newtonsoft.Json confilict in vs2015 - c#

I try to build the Akka.NET as build all ,but there is a error:
CS0433: Configuration\Hocon\HoconObject.cs(47,10): The type 'JsonIgnoreAttribute' exists in both 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' and 'Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
I don't know why the vs2015 will to find the 'Newtonsoft.Json' in foler C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\ not the reference path ..\..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll.
Here is the akka.net project file Akka.csproj.
Please help me to solve the problem.Thanks
--------------------Update---------------
I found the Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll as follow:
Is there a problem in Nuget now?

I got similar kind of error once and Solved this by renaming the Dll and adding it to reference.
The other way around is you copy the DLL version to the bin of the project and then add it to reference.
Each time you are building as you referred, visual studio is downloading the latest package and hence this conflict arises.
I would suggest you to go for the second approach.
Thanks,
Anil

I had the same issue, what fixed it for me:
Delete bin and obj folders,
Uninstall-Package Akka, then
Install-Package Newtonsoft.Json to latest version (8.0+)
Then, Install-Package Akka,
which will pick up the latest version of Newtonsoft.Json and be happy :).

Related

Could not load file or assembly. The located assembly's manifest definition does not match the assembly reference. Version conflict

I am having an error when I want to run my program. The error states that it could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference.
I have checked on my target framework and package reference which I am now using net5.0 framework for my project. But the version of System.Runtime seems to be net6.0 framework. I have checked on my System.Runtime that the version is 5.0.0.0. So obviously the version 6.0.0.0 is missing. Does anyone know how to change the version of System.Runtime to be 5.0.0.0?
Error Message
System Runtime Details
.csproj file
Okay, so i just delete my bin and obj folder and proceed to clean and rebuild my project and it works perfectly. Wasted two days for this.
Got the inspiration from this link.
Credit to Levi Fuller's comment

Install Microsoft.SqlServer.Types in GAC

How do I install Microsoft.SqlServer.Types assembly in GAC (C:\Windows\assembly\GAC_MSIL). It is missing.
I am getting error after running rdlc report. it is MVC based application-
Could not load file or assembly 'Microsoft.SqlServer.Types,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=token' or one of its
dependencies.
It seems application is looking Microsoft.SqlServer.Types assembly in GAC. I know how to install using nuget in project folder but I want it in GAC.
Don’t try to GAC it. Add the NuGet package to your project instead.
https://www.nuget.org/packages/Microsoft.SqlServer.Types

Could not load file or assembly Nuget packages

I have an ASP.Net project which has several sub projects referenced.
I decided today to update some of my nuget packages to have newer versions, what a mistake it was.
Now when I try to debug my app I get this exception:
System.IO.FileNotFoundException: 'Could not load file or assembly
'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The
system cannot find the file specified.'
InnerException : FileNotFoundException: Could not load file or assembly
'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The
system cannot find the file specified.
It seems like it's looking to load 6.0.0.0 which is not referenced by any of my subprojects, maybe one of the other nugetpackages ?
I've followed several questions here to perform different operations including:
- Deleting packages folder in Windows Explorer
- Reinstalling the Newtonsoft.Json package
- Clearing the cache of the package in the settings of VS
- Restoring the packages
- Cleaning my solution
- Restarting VS
I'm using VS 2017 community.
I tried to update several other packages to see if it could be linked and I got many new exceptions so I just decided to stop the mess and rollback everything.
But the problem is still here after the rollback so i'm really unsure about what I should do now.
Links I've checked before: Nuget package installed but references not resolved
https://learn.microsoft.com/en-us/nuget/consume-packages/package-restore-troubleshooting

Assembly conflict after upgrading package

I have a OneClick program, Project A, that references class library project B. Project B had Json.net version 4.5.0.0 that was upgraded to 7.0.0.0. Upon building project A I get the error messages:
No way to resolve conflict between "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from Version "4.5.0.0" [C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll] to Version "7.0.0.0" [[projectpath]\Newtonsoft.Json.dll] to solve conflict and get rid of warning.
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1697,5): warning MSB3276: Found conflicts between different versions of the same dependent assembly. Please set the "AutoGenerateBindingRedirects" property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.
I have cleaned every project in the solution and rebuilt them. I've closed/opened VS, recleaned, rebuilt, same thing. Manually deleted obj + bin folders, same thing.
I've changed the Settings/Publish/Application Files menu to every variation of inclusion/exclusion for json.net.
And finally, I've global searched in Sublime(VS doesn't pick up everything) for 4.5.0.0 and come up with virtually nothing except the json.net references in the manifest files project A creates. I can't seem to find a single lingering reference to the old library, yet it keeps ending up in the manifest upon building.
I've solved my problem by adding <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> in the .csproj's relevant <PropertyGroup>s, but I'm not sure why it works. Can anyone explain to me what's going on? Is this a bad way to solve this problem?

Annoying log4net assemly reference issue in vs 2012

Getting following build error.
Error 15 Unknown build error, 'Could not load file or assembly
'log4net, Version=1.2.11.0, Culture=neutral,
PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040)'
I dont quite get whats going on.
I tried using GUI for references, it didn't help. Spent 1.5 hours on this already and issue is still present.
I go directly to project file now and the only reference to log4net there is the following:
<Reference Include="log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ExternalDlls\.NET 4.0\log4net.dll</HintPath>
</Reference>
I still get this error. Why does it even mention V1.2.11?
Thanks in advance
Okay got build working finally.
I went through all other projects and did Resharper - Remove unused references action.
After it was done, project started to build.
Can you check what version actually exists in the Path ....\ExternalDlls.NET 4.0\log4net.dll mentioned and see what version is present in GAC.
Remove the version in GAC, remove the below reference the from project file and add it again from the ExternalDlls folder
<Reference Include="log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\ExternalDlls\.NET 4.0\log4net.dll</HintPath>
</Reference>
If you are creating a nuget package that is referencing log4net make sure your nuspec file is specifying the correct version of log4net (this is the problem I ran into after log4net released the new build). And make sure that if you don't want the latest version of log4net you encapsulate your version with "[" and "]" so that it doesn't get the latest. See this.. http://docs.nuget.org/docs/reference/versioning#Specifying_Version_Ranges_in_.nuspec_Files
Hope this helps someone.
I am facing this issue today. To solve this problem I deleted log4net.dll file reference from Bin Folder through visual studio. and rebuild the website.
It automatically picks up log4net dll. This solved problem. Reason for this issue was Reference bind through visual studio may not be upto date with the actual file version.

Categories

Resources