Using Microsoft Visual Studio 2022 to build a C# Web API project with .NET 6 Framework, the project builds fine on one machine. I cloned the same source code repository into a different machine, but when building in the new machine I get the following error:
FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.ComputeManifestHash()
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.Create(String source, String basePath, String mode, String manifestType, ReferencedProjectConfiguration[] referencedProjectConfigurations, DiscoveryPattern[] discoveryPatterns, StaticWebAsset[] assets)
at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute()
ResultsMonitor.API C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 411
Severity Code Description Project File Line Suppression State
Error FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.ComputeManifestHash()
at Microsoft.AspNetCore.Razor.Tasks.StaticWebAssetsManifest.Create(String source, String basePath, String mode, String manifestType, ReferencedProjectConfiguration[] referencedProjectConfigurations, DiscoveryPattern[] discoveryPatterns, StaticWebAsset[] assets)
at Microsoft.AspNetCore.Razor.Tasks.GenerateStaticWebAssetsManifest.Execute()
ResultsMonitor.API C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets 411
Furthermore, on the new machine:
If I use JetBrains Rider 2022.1.1 to open the same project, it just builds and runs fine.
If I do a "dotnet build" from the terminal, build also succeeds.
What is wrong with Visual Studio 2022? I even uninstalled and reinstalled Visual Studio 2022 and the .NET 6 SDK for Visual Studio
I have a C# "MyAssembly" .NET 2.0 assembly referenced by a C# "MyAssemblyTester" .NET 2.0 exe.
I am using Visual Studio Express 2015.
Both projects compile and work fine.
If I add to "MyAssembly" project a reference to a very old OCX (before year 2000: Teechart Pro Activex 4.0.1.7, but I had the same problem with other old COM DLL components) and recompile, the "MyAssembly" project compiles and link fine, but I have a lot of errors for "MyAssemblyTester" like this:
2>------ Rebuild All started: Project: MyAssemblyTester, Configuration: Debug x86 ------
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3268: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "MyAssembly" or retarget your application to a framework version which contains "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "Accessibility, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Deployment, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Runtime.Serialization.Formatters.Soap, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3268: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the framework assembly "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "MyAssembly" or retarget your application to a framework version which contains "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
If I change the target framework for both "MyAssembly" and "MyAssemblyTester" to .NET 4.0, the problem is solved. However, due to backward compatibility, I want to have a .NET 2.0 target framework.
I think that the source of the problem is that the Interop assemblies (AxInterop.TeeChart.dll and Interop.TeeChart.dll) generated by VS2015 target .NET 4.0.
Indeed ILSpy output for AxInterop.TeeChart.dll is:
// AxInterop.TeeChart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Global type: <Module>
// Architecture: AnyCPU (64-bit preferred)
// Runtime: .NET 4.0
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AxHost.TypeLibraryTimeStampAttribute("05/13/2009 16:17:54")]
// System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// Interop.TeeChart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
// System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
And Interop.TeeChart.dll is similar.
Some pieces of the detailed build log (1> is MyAssembly and 2> MyAssemblyTester):
...
1>Using "ResolveComReference" task from assembly "Microsoft.Build.Tasks.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
1>Task "ResolveComReference"
1> Creating new cache file at "obj\x86\Debug\MyAssembly.csproj.ResolveComReference.cache".
1> Adding a matching tlbimp reference for the aximp reference "AxTeeChart".
1> Resolving COM reference for item "stdole" with a wrapper "primary".
1> Determining dependencies of the COM reference "stdole".
1> Resolved COM reference for item "stdole": "C:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll".
1> Resolving COM reference for item "AxTeeChart" with a wrapper "primaryortlbimp".
1> Determining dependencies of the COM reference "AxTeeChart".
1> C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\TlbImp.exe C:\Windows\SysWOW64\teechart.ocx /namespace:TeeChart /machine:X86 /out:obj\x86\Debug\Interop.TeeChart.dll /sysarray /transform:DispRet /reference:"C:\Program Files (x86)\ABCD\abcdSDK\DLL\x86\abcdsdk.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:C:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll
1> Microsoft (R) .NET Framework Type Library to Assembly Converter 4.6.81.0
1> Copyright (C) Microsoft Corporation. All rights reserved.
1>
1> TlbImp : Type library imported to C:\repSVN\Prod2NCG2\prodmspeqspcp\trunk\src\MyAssembly\obj\x86\Debug\Interop.TeeChart.dll
1> Resolved COM reference for item "AxTeeChart": "obj\x86\Debug\Interop.TeeChart.dll".
1> Resolving COM reference for item "AxTeeChart" with a wrapper "aximp".
1> Determining dependencies of the COM reference "AxTeeChart".
1> C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\AxImp.exe C:\Windows\SysWOW64\teechart.ocx /out:obj\x86\Debug\AxInterop.TeeChart.dll /rcw:obj\x86\Debug\Interop.TeeChart.dll
1> Generated Assembly: C:\repSVN\Prod2NCG2\prodmspeqspcp\trunk\src\MyAssembly\obj\x86\Debug\AxInterop.TeeChart.dll
1> Resolved COM reference for item "AxTeeChart": "obj\x86\Debug\AxInterop.TeeChart.dll".
1>Done executing task "ResolveComReference".
1>Done building target "ResolveComReferences" in project "MyAssembly.csproj".
...
...
...
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3258: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which has a higher version "4.0.0.0" than the version "2.0.0.0" in the current target framework.
...
...
...
2>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3268: The primary reference "MyAssembly" could not be resolved because it has an indirect dependency on the framework assembly "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "MyAssembly" or retarget your application to a framework version which contains "System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
2> Primary reference "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
2> Resolved file path is "C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll".
2> Reference found at search path location "C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll".
2> This reference is not "CopyLocal" because it's a prerequisite file.
2> The ImageRuntimeVersion for this reference is "v2.0.50727".
2> Primary reference "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
2> Resolved file path is "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll".
2> Reference found at search path location "{TargetFrameworkDirectory}".
2> For SearchPath "{TargetFrameworkDirectory}".
2> Considered "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.winmd", but it didn't exist.
2> This reference is not "CopyLocal" because it's a prerequisite file.
2> The ImageRuntimeVersion for this reference is "v2.0.50727".
2> Resolved file path is "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll".
...
...
...
2> Reference found at search path location "{TargetFrameworkDirectory}".
2> For SearchPath "{TargetFrameworkDirectory}".
2> Considered "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.winmd", but it didn't exist.
2> This reference is not "CopyLocal" because it's a prerequisite file.
2> The ImageRuntimeVersion for this reference is "v2.0.50727".
2>Done executing task "ResolveAssemblyReference".
....
How could I manually change the target framework for Interop assemblies?
Maybe I need to change the AxImp and TlbImp path or some of their options?
Any other idea?
Thank you
I finally solved installing "Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1", then adding to "Post-build event command line":
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\TlbImp.exe" C:\Windows\SysWOW64\teechart.ocx /namespace:TeeChart /machine:X86 /out:$(TargetDir)\Interop.TeeChart.dll /sysarray /transform:DispRet /reference:"C:\Program Files (x86)\ABCD\abcdSDK\DLL\x86\abcdsdk.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:C:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\AxImp.exe" C:\Windows\SysWOW64\teechart.ocx /out:$(TargetDir)\AxInterop.TeeChart.dll /rcw:$(TargetDir)\Interop.TeeChart.dll
(copied the commands from the detailed build log, changed the path for AxImp and TlbImp to the 3.5 SDK and the output paths for the Interop assemblies from obj\x86\Debug to $(TargetDir)).
I wonder whether there is a cleaner solution.
I have Visual Studio project that I am trying to get running with Mono.
I could install all dependencies using
mono nuget.exe install
and compile my application using
mcs -r:RestSharp.105.2.3/lib/net46/RestSharp.dll \
-r:JWT.1.3.4/lib/3.5/JWT.dll \
-r:jose-jwt.2.2.0/lib/net461/jose-jwt.dll \
-r:Newtonsoft.Json.10.0.1/lib/net45/Newtonsoft.Json.dll \
Program.cs
Now I am trying to run the application using
mono Program.exe
Unhandled 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.
File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
[ERROR] FATAL UNHANDLED 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.
File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
So how do you pass the path to the assemblies to the Mono runtime similar to the compiler?
I tried to set $MONO_PATH but this is not working and not recommended for Production.
The overall question how the mcs compiler and the mono runtime could get the information directly from the installed packages (using nuget.exe).
Seems like I get this weird problem while running Xamarin.iOS on Visual studio.
This happened after I updated to the latest Xamarin (today).
I have connected to my Mac though. I tried to Google it, no answer...
"error MSB4057: The target "GetBuiltProjectOutputRecursive" does not exist in the project"
What is the problem? Before the update, it worked!
1>------ Build started: Project: GTS.Mobile.iOS, Configuration: Debug iPhoneSimulator ------
1> Generated session id: 04dbf5285bd918e0f3e1fc41e6f65f8c
1> Generated build app name: GTSMobileiOS
1> Connecting to Mac server 192.168.9.164...
1>C:\Users\kkh\Computas\CargoNet\GTS.Mobile\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets(243,5): warning : All projects referencing GTS.Mobile.csproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
1> Consider app.config remapping of assembly "System.Runtime, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "1.5.11.0" [] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Runtime.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.IO, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "1.5.11.0" [] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.IO.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Net.Http, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "1.5.0.0" [C:\Users\kkh\Computas\CargoNet\GTS.Mobile\GTS.Mobile\GTS.Mobile\bin\Debug\System.Net.Http.dll] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\System.Net.Http.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Threading.Tasks, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" from Version "1.5.11.0" [] to Version "4.0.0.0" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Threading.Tasks.dll] to solve conflict and get rid of warning.
1>C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,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.
1> GTS.Mobile.iOS -> C:\Users\kkh\Computas\CargoNet\GTS.Mobile\GTS.Mobile.iOS\bin\iPhoneSimulator\Debug\GTSMobileiOS.exe
1>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.After.targets(59,36): error MSB4057: The target "GetBuiltProjectOutputRecursive" does not exist in the project.
I have solved the problem on my own installation.
Here is what i did:
Install the newest xamarin on both visual studio and mac.
Install xamarin studio (newest)
Remove all xamarin products including gtk.
Install xamarin newest(complete pack) with the installer
Reboot computer
Open solution and clean/build
I'm not able to build the solution in Visual Studio 2013.
This just happened after I updated my JSON.NET package to 6.0.1. Before that, it was working like a charm.
Any ideas?
PS: It's probably something about OWIN. It references JSON.NET too I think, maybe dynamically?
Full error
Error 11 The type 'Newtonsoft.Json.Linq.JObject' exists in both
'c:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll' and
'c:\Users\Me\Desktop\Solutions\[Project]\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll'
C:\Users\Me\Desktop\Solutions\[Project]\TrendPin\App_Start\Startup.Auth.cs 48 21 [Project]
I have this in my Web.Config
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
I have this in my .csproj
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
Build Output
1>------ Build started: Project: [Project].Backend, Configuration: Debug Any CPU ------
1> All packages listed in packages.config are already installed.
1>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3277: Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.
1> [Project].Backend -> C:\Users\Me\Desktop\Solutions\[Project]\[Project].Backend\bin\Debug\[Project].Backend.dll
2>------ Build started: Project: [Project].Data, Configuration: Debug Any CPU ------
2> All packages listed in packages.config are already installed.
2> [Project].Data -> C:\Users\Me\Desktop\Solutions\[Project]\[Project].Data\bin\Debug\[Project].Data.dll
3>------ Build started: Project: [Project], Configuration: Debug Any CPU ------
3> All packages listed in packages.config are already installed.
3>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3243: 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.
3> 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 "6.0.0.0" [C:\Users\Me\Desktop\Solutions\[Project]\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll] to solve conflict and get rid of warning.
3>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(1635,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly. In Visual Studio, double-click this warning (or select it and press Enter) to fix the conflicts; otherwise, add the following binding redirects to the "runtime" node in the application configuration file: <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" /><bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /></dependentAssembly></assemblyBinding>
3>C:\Users\Me\Desktop\Solutions\[Project]\[Project]\App_Start\Startup.Auth.cs(48,21,48,28): error CS0433: The type 'Newtonsoft.Json.Linq.JObject' exists in both 'c:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\Newtonsoft.Json.dll' and 'c:\Users\Me\Desktop\Solutions\[Project]\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll'
4>------ Skipped Build: Project: [Project].Tests, Configuration: Debug Any CPU ------
4>Project not selected to build for this solution configuration
========== Build: 2 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========
In your csproj file you will notice that there are 2 entries for Newtonsoft.Json. Remove the following entry:
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.6\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
You can reflect owin and see what is it looking for in references. If it looks for specific version, you in trouble but if not, just put the version you want into application bin together with owin and hope that the signatures match. Also remember, there is GAC. So, you have room for experimentation
I had almost the same issue after doing a merge. Turns out the merge left two references to Newtonsoft.Json in the csproj file. There was on DLL in the project and only one version in the NuGet package manager, but the csproj referenced Newtonsoft.Jason 5.0.6 and 5.0.8
I edited the csproj in notepad++ and removed the offending reference, et voila. It solved the build errors