Found conflicts between different versions of "Newtonsoft.Json" that could not be resolved - asp.net-web-api2

After upgrading VS2019 Enterprise edition to latest version: 16.9.4 , when I tried to build a project with Target Framework: NET Framework 4.7.2 , I am getting the below errors :
Found conflicts between different versions of "Newtonsoft.Json" that could not be resolved.
7>c:\program files (x86)\microsoft visual studio\2019\enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3277: There was a conflict between "Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed".
7>c:\program files (x86)\microsoft visual studio\2019\enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3277: "Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" was chosen because it was primary and "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" was not.
7>c:\program files (x86)\microsoft visual studio\2019\enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3277: References which depend on "Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" [<Path to the project>\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll].
7>c:\program files (x86)\microsoft visual studio\2019\enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3277: <Path to the project>\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
7>c:\program files (x86)\microsoft visual studio\2019\enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3277: Project file item includes which caused reference "<Path to the project>\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll".
7>c:\program files (x86)\microsoft visual studio\2019\enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2182,5): warning MSB3277: Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL
Similarly for System.Net.Http.Formatting , System.Web.Http
Can anyone help me here by providing their guidance in fixing this issue

Unfortunately things like this are a bit of a pain to resolve. If you open the Error List window (View --> Error List) you'll get a bit more detail. There should be a warning in the Error List with the dependencies causing the conflict. It's not intuitive what's causing the problem but you can figure it out if you spend the time reading through the entire warning. Essentially it boils down to getting packages to versions where all the dependencies are consistent.

Related

VS 2019, VB, Class Library, getting error "Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral" during RegAsm

It's my 1st time trying to build a .DLL in .Net, for use with a VB5 program...I'm a newbee
Windows 10, VS 2019, VB, building a Class Library Target framework is .NET Core 3.1.
RestSharp 106.15.0 in Assemblies, Newtonsoft.Json 13.0.1
getting error
"C:\Users\User\Desktop\PSMdata\aaaOther>regasm.exe IQProLnk.dll /tlb:IQProLnk.tlb
Microsoft .NET Framework Assembly Registration Utility version 4.8.4084.0
for Microsoft .NET Framework version 4.8.4084.0
RegAsm : error RA0000 : Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified."
I've looked at everything I could find doing a Google search.
I've tried adding a System.Runtime through NuGet, but all I could find is 4.3.1.... it still wants 4.2.2.0
As suggested by someone who did a C# program and had the same problem, I've added (to no avail):
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken= "b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="4.0.0.0"/>
</dependentAssembly>
to "C:\Users<user>\AppData\Local\Microsoft\VisualStudio\16.0_cd2f1afe\devenv.exe.config"
Some one suggested "modify the app.config entry to match packages.config for the newVersion", but I cannot find either one of those config files. But this was for VS 2017 anyhow.
I've searched all the files in the IQProLnk subdirectories for any reference to System.Runtime and all I found was this in the IQProLnk.vbproj file after I added System.Runtime in NuGet
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
</ItemGroup>
Otherwise I don't know what it is that wants v4.2.2.0.
I hope I haven't been to verbose but did give enough information.
Thanks

How to resolve warning messages of type: No way to resolve conflict between DLLs

I have a Windows service application made with VB.NET under Visual Studio 2013 and using NET Framework 4.5. I am using Nuget in this project.
Once I build the solution (it builds successfully) I get below warning messages in the results window:
No way to resolve conflict between "Microsoft.ReportViewer.ProcessingObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "Microsoft.ReportViewer.ProcessingObjectModel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.ReportViewer.ProcessingObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" arbitrarily.
No way to resolve conflict between "Microsoft.ReportViewer.DataVisualization, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "Microsoft.ReportViewer.DataVisualization, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.ReportViewer.DataVisualization, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" arbitrarily.
No way to resolve conflict between "Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" and "Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". Choosing "Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" arbitrarily.
No way to resolve conflict between "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
No way to resolve conflict between "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" and "Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed". Choosing "Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" arbitrarily.
Consider app.config remapping of assembly "Newtonsoft.Json, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed" from version "9.0.0.0" [] to version "11.0.0.0" [C:\MyProjects\WindowsServices\MyService\packages\Newtonsoft.Json.11.0.1\lib\net45\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: Microsoft.Common.CurrentVersion.targets Found conflicts between different versions of the same dependent assembly.
Please set the "AutoGenerateBindingRedirects" property to true in the project file. For further information, see http://go.microsoft.com/fwlink/?LinkId=294190.
I have been searching for information about this, and I have found some posts and blogs talking about that:
No Way to Resolve Conflict Between dlls
No Way to Resolve Conflict Between dlls
I have tried to clean up all the references in the VB.NET project that were not being used but above warning messages continue appearing.
Also I have gone into Manage NuGet Packages but I have not seen any duplicate packages in the list.
I don't see the duplicates anywhere (vbproj project file, app.config, etc.). Where can I find those duplicates? Where are the duplicates? How to search for the duplicates?
Finally, I know there is another way to resolve those conflicts (I have not tried yet) and it consists on adding binding redirects for all the assemblies that are conflicted in the app.config file. For example, in case of ClosedXML DLL:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="ClosedXML" publicKeyToken="fd1eb21b62ae805b" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.85.0.0" newVersion="0.85.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Instead of adding manually confliting assemblies in the app.config file, I know it can be done automatically by Visual Studio by adding the property entry below in the vbproj project file:
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
as explained here.
Anyway, I would like to resolve those conflicts without binding redirects for all the conflicted assemblies in the app.config file. So Is that possible? If so, how?
Also I have some other questions in mind:
Binding redirects for conflicted assemblies in the app.config file
is a good practice?
Why those conflicts between assemblies happen? I do not understand it at all, so please could you explain me this?
What happens if I not resolve those conflicts and I ignore them (since solution is build successfully without errors)? Is it mandatory or highly recomended to resolve them for any kind of reason that I currently do not know?

The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime" from TeamCity

I'm getting the above error from our TeamCity build.
I have tried adding the following lines to the web.config.
<assemblies>
<add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</assemblies>
I have also installed the latest Windows SDK for .NET4.5.2.
Neither of these have resolved the error.
Any ideas?
Finally found a solution to this problem. I added a reference to the System.Runtime.dll assembly to my project. I added a reference to the following file to my project (substitute your own version of .NET in the path as necessary). You could always copy the file to your project folder and link it from there as an alternative.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\Facades
This worked for me and hopefully will work for someone else.

System.Data.OracleClient Missing From .NET 4.0?

I'm having trouble building my .NET 4.0 application. Getting this warning:
The primary reference "Microsoft.Practices.EnterpriseLibrary.Data,
Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" could not be resolved because it has an
indirect dependency on the framework assembly
"System.Data.OracleClient, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" which could not be resolved in the
currently targeted framework. ".NETFramework,Version=v4.0". To resolve
this problem, either remove the reference
"Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35,
processorArchitecture=MSIL" or retarget your application to a
framework version which contains "System.Data.OracleClient,
Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089". EBRX
The solution has three projects in it, all of which are pointing at the 4.0 framework (not client). Still getting the error. Can anyone help?
Thanks in advance,
Brandon
Please make sure that you have a reference to System.Data.OracleClient:
Just for your notice:
The Types in System.Data.OracleClient (.NET Framework 4) namespace are deprecated and will be removed in a future version of the .NET Framework.
As you can see on https://msdn.microsoft.com or http://blogs.msdn.com.

GAC assembly found but not in C:\Windows\assembly\

Notice how the 4.0 version of the ODP.NET Oracle Provider (Oracle.DataAccess.dll) shows up in the GAC when I search for it using the gacutil.exe utility. But it doesn't exist in the C:\windows\assembly\ folder. Why would that be? How can I find and extract that dll from the GAC? Only the 2.x assemblies are in the folder.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>gacuti
l /l Oracle.DataAccess
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.33440
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f4
29c47342, processorArchitecture=x86
Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f4
29c47342, processorArchitecture=x86
Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f4
29c47342, processorArchitecture=x86
Number of items = 3
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools>
Looks like the dll was in a different folder.
C:\Windows\Microsoft.NET\assembly\GAC_32\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342\oracle.dataaccess.dll