Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0 when using Atlassian.SDK 10.6.0 - json.net

My project is using Nuget package Atlassian.SDK 10.6.0.
When calling
var jc = Atlassian.Jira.Jira.CreateRestClient(_jiraBaseUrl, _jiraApiUsername, _jiraApiPassword);
I have the error
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=10.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)
My web.config already has the bindingRedirect
<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>
I also checked the fusion log
Calling assembly : Atlassian.Jira, Version=10.6.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: F:\Titan\AutoLedgers\Facade\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET Files/facade/a6115f90/89f913a7/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary
ASP.NET
Files/facade/a6115f90/89f913a7/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///F:/Titan/AutoLedgers/Facade/bin/Newtonsoft.Json.DLL.
LOG: Assembly download was successful. Attempting setup of file: F:\Titan\AutoLedgers\Facade\bin\Newtonsoft.Json.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I really have no idea how can I resolve this issue now. Does anyone has any idea?

Related

Cannot load file or assembly 'System.Runtime'

I have an Asp.Net 4.7 WebForms legacy application written in vb.net. To add Azure B2C authentication, I add OWIN middleware NuGet packages like this:
Install-Package Microsoft.Owin.Security.OpenIdConnect
Install-Package Microsoft.Owin.Security.Cookies
Install-Package Microsoft.Owin.Host.SystemWeb
based on this tutorial: https://learn.microsoft.com/en-us/azure/active-directory/develop/tutorial-v2-asp-webapp
When I try to run the application, I get this error:
Could not load file or assembly 'System.Runtime, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
Here is the log:
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\IIS Express\iisexpress.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=...
(Fully-specified)
LOG: Appbase = file:///C:/Git Repos/InfoWeb/
LOG: Initial PrivatePath = C:\Git Repos\InfoWeb\bin
Calling assembly : System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=....
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Git Repos\InfoWeb\web.config
LOG: Using host configuration file: C:\Users\dreznik\OneDrive - MyCompany\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.0.0.0 redirected to 4.1.1.0.
LOG: Post-policy reference: System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=...
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/vs/17153f21/a2ffde83/System.Runtime/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Git Repos/InfoWeb/bin/System.Runtime/System.Runtime.EXE.
How can this be resolved? I have already tried to delete temporary Asp.Net files.
You must check that assemblyBinding subsection inside runtime section of web.config file have correct value that define System.Runtime.
It must be something like this
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="4.0.0.0-4.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime

Wrong version of .NET assembly getting copied to Web Forms bin directory

I'm working on an ASP.NET Web Forms web site and frequently get run-time exceptions like the following:
Could not load file or assembly 'Newtonsoft.Json, Version=4.5.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)
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
(Fully-specified)
LOG: Appbase = file:///C:/Code/MyProject/
LOG: Initial PrivatePath = C:\Code\MyProject\bin
Calling assembly : System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Code\MyProject\web.config
LOG: Using host configuration file: \\foo\bar\Profile.v2\simonm\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 4.5.0.0 redirected to 11.0.0.0.
LOG: Post-policy reference: Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Users/simonm/AppData/Local/Temp/Temporary ASP.NET Files/vs/8d6ca9e7/1d38a78a/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/simonm/AppData/Local/Temp/Temporary ASP.NET Files/vs/8d6ca9e7/1d38a78a/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Code/MyProject/bin/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.
They're invariably because the "wrong" version of an assembly (it always seems to be Newtonsoft.Json) gets copied to the Bin directory despite the fact that the packages.config in the root of the site has:
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" />
and the web.config contains:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
Can somebody please explain what dictates which assembly gets copied to the Bin directory, why this keeps happening and how to prevent it from happening in the future?
I guess, that some of your used frameworks/libraries are using different versions of Newtonsoft.Json. First, check your frameworks/libraries if they are requiring different versions of the Newtonsoft.Json library.
When you detected which is the (minimum) required version of Newtonsoft.Json try to reinstall this version through Nuget.
This seems to be cause by a number of factors, but ultimately boils down to having a .refresh file in the Bin directory that points to a different version of the assembly than the one referenced in the web.config.
It looks like these .refresh files get added when you (either manually or automatically due to e.g. Update-Package) add a reference to an ASP.NET project. If you look at the contents of a .refresh file, it's just the path to a .dll file. When you build, MSBuild (I assume) checks whether the Foo.dll in your Bin directory matches the one referenced by Foo.dll.refresh and, if they don't, copies the one referenced by the .refresh file into your Bin.
I think this combined with switching branches in Git to one that has a reference to a different version referenced in the web.config combined with the .refresh files not being in version control is what causes these problems.

Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.

I downloaded the web app from my company's server and running it on my machine. It works well except when I click on one of the menu items (all the others are good). It is showing me this error. I checked my web.config and the version I set for web.mvc is 4.0.0.0. I have no idea how is this happen.
I checked the similar problem on the websites but the solutions are not working for me. Here is the assembly load trace info that might be helpful:
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///%working root%/WebApplication/
LOG: Initial PrivatePath = %working root%\WebApplication\bin
Calling assembly : App_Web_e4sj14ak, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file: %working root%\WebApplication\web.config
LOG: Using host configuration file: C:\Users\Kevin\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/Kevin/AppData/Local/Temp/Temporary ASP.NET Files/root/57d1caa4/e98fbd78/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Users/Kevin/AppData/Local/Temp/Temporary ASP.NET Files/root/57d1caa4/e98fbd78/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///%working root%/WebApplication/bin/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///%working root%/WebApplication/bin/System.Web.Mvc/System.Web.Mvc.DLL.
LOG: Attempting download of new URL file:///C:/Users/Kevin/AppData/Local/Temp/Temporary ASP.NET Files/root/57d1caa4/e98fbd78/System.Web.Mvc.EXE.
LOG: Attempting download of new URL file:///C:/Users/Kevin/AppData/Local/Temp/Temporary ASP.NET Files/root/57d1caa4/e98fbd78/System.Web.Mvc/System.Web.Mvc.EXE.
LOG: Attempting download of new URL file:///%working root%/WebApplication/bin/System.Web.Mvc.EXE.
LOG: Attempting download of new URL file:///%working root%/WebApplication/bin/System.Web.Mvc/System.Web.Mvc.EXE.
I am really confused that I am using MVC4 but the error message is version of 3.0.0.0. This problem has annoyed me for a long time. Please help me and thanks in advance.
Problem solved by installing MVC 3.0 in my computer. Now it's working.
On your web.config, be sure to have this inside assemblyBinding section
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
It forces to use 4.0.0.0 no matter what assembly version is trying to bind

Running two versions of MongoDB assemblies at the same time

All,
My Project - (VS 2010 / .NET 4 / ASP.NET application, my web application lives inside Sitefinity as a Sitefinity application)
I have two versions of the MongoDB assemblies. I would like to run these side-by-side in my web application. Here's my setup:
\bin\AuxFiles\[1.8.3.9] assemblies
\bin\[1.4.x.x] assemblies
Web config:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MongoDB.Bson" publicKeyToken="f686731cfb9cc103" culture="neutral" />
<codeBase version="1.4.2.4500" href="bin\MongoDB.Bson.dll" />
<codeBase version="1.8.3.9" href="bin\AuxFiles\MongoDB.Bson.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MongoDB.Driver" publicKeyToken="f686731cfb9cc103" culture="neutral" />
<codeBase version="1.4.2.4500" href="bin\MongoDB.Driver.dll" />
<codeBase version="1.8.3.9" href="bin\AuxFiles\MongoDB.Driver.dll" />
</dependentAssembly>
</assemblyBinding>
When the application starts, it loads the 1.4.x.x assemblies by default. When I go to the page that uses the 1.8.3.9 version of assemblies I get an error:
Server Error in '/' Application.
Could not load file or assembly 'MongoDB.Driver, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'MongoDB.Driver, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error: ....
Source File: ...... Line: 18
Assembly Load Trace: The following information can be helpful to determine why the assembly 'MongoDB.Driver, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = MongoDB.Driver, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103
(Fully-specified)
LOG: Appbase = file:///C:/DEV/Visual Studio 2010/WebStoreApp/WebStoreApp/
LOG: Initial PrivatePath = C:\DEV\Visual Studio 2010\WebStoreApp\WebStoreApp\bin
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\DEV\Visual Studio 2010\WebStoreApp\WebStoreApp\web.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: MongoDB.Driver, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d73c4379/cb2aee95/MongoDB.Driver.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d73c4379/cb2aee95/MongoDB.Driver/MongoDB.Driver.DLL.
LOG: Attempting download of new URL file:///C:/DEV/Visual Studio 2010/WebStoreApp/WebStoreApp/bin/MongoDB.Driver.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Stack Trace:
[FileLoadException: Could not load file or assembly 'MongoDB.Driver, Version=1.8.3.9, Culture=neutral, PublicKeyToken=f686731cfb9cc103' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint
UPDATE 1:
I have tried to rename my new 1.8.x.x assemblies from MongoDB.Driver.dll to MongoDB.Driver.exe so the files can co-exist under same directory (the older assemblies have extension .dll, the new version of the assemblies have extension .exe) but the loader seems not to pickup the assemblies. My understanding is that the loader always tries .dlls first, then tries .exes second. I am a bit puzzled.
UPDATE 2:
I have created a console application w/ exactly identical setup of my dual references and the app config entries that you see here,- and the application works, it executes 2 versions of the Mongo dll. The question is now, why doesn't this setup work in my Web application? Are my directories wrong? If you look below at the probing for the assemblies, it never checks my AuxFiles directory, it appears it simply ignores my configuration for side-by-side execution in web.config.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d73c4379/cb2aee95/MongoDB.Driver.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d73c4379/cb2aee95/MongoDB.Driver/MongoDB.Driver.DLL.
LOG: Attempting download of new URL file:///C:/DEV/Visual Studio 2010/WebStoreApp/WebStoreApp/bin/MongoDB.Driver.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
UPDATE 3:
Found the issue but I am not sure of the details of this solution. The web.config file has 'configuration' root element w/ the following namespace declaration - 'xmlns=http://schemas.microsoft.com/.NetConfiguration/v2.0'.
The root element is fine but the specified namespace is causing my 'runtime' element to be ignored. Removing the namespace from the configuration element fixes everything.
Found the issue:
The 'configuration' root element in the web.config file contains the following namespace declaration - 'xmlns=http://schemas.microsoft.com/.NetConfiguration/v2.0'. Removing the namespace from the configuration element fixes everything.
Why the ns? It is more of a bug then anything in VS and has really no real purpose but mess up your intellisense and in my case the runtime configuration. Read more about it:
http://weblogs.asp.net/scottgu/archive/2005/12/02/432077.aspx

website compile error

I am experiencing the following error while loading a website:
Server Error in '/DatingGridView' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 52:
Line 53:
Line 54:
Line 55:
Line 56:
Source File: D:\VSProjects\DatingGridView\web.config Line: 54
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
=== Pre-bind state information ===
LOG: User = PassionFruit-PC\PassionFruit!!!
LOG: DisplayName = System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///D:/VSProjects/DatingGridView/
LOG: Initial PrivatePath = D:\VSProjects\DatingGridView\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: D:\VSProjects\DatingGridView\web.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
LOG: Post-policy reference: System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/PassionFruit!!!/AppData/Local/Temp/Temporary ASP.NET Files/datinggridview/5a514f00/39d65547/System.Web.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/Users/PassionFruit!!!/AppData/Local/Temp/Temporary ASP.NET Files/datinggridview/5a514f00/39d65547/System.Web.Extensions/System.Web.Extensions.DLL.
LOG: Attempting download of new URL file:///D:/VSProjects/DatingGridView/bin/System.Web.Extensions.DLL.
LOG: Attempting download of new URL file:///D:/VSProjects/DatingGridView/bin/System.Web.Extensions/System.Web.Extensions.DLL.
LOG: Attempting download of new URL file:///C:/Users/PassionFruit!!!/AppData/Local/Temp/Temporary ASP.NET Files/datinggridview/5a514f00/39d65547/System.Web.Extensions.EXE.
LOG: Attempting download of new URL file:///C:/Users/PassionFruit!!!/AppData/Local/Temp/Temporary ASP.NET Files/datinggridview/5a514f00/39d65547/System.Web.Extensions/System.Web.Extensions.EXE.
LOG: Attempting download of new URL file:///D:/VSProjects/DatingGridView/bin/System.Web.Extensions.EXE.
LOG: Attempting download of new URL file:///D:/VSProjects/DatingGridView/bin/System.Web.Extensions/System.Web.Extensions.EXE.
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
Your error clearly states:
Could not load file or assembly 'System.Web.Extensions'
Check that you are referencing this in your project and that your .NET framework is installed correctly.
System.Web.Extensions is required for MS Ajax and will appear in your D:\VSProjects\DatingGridView\web.config to enable the correct handlers for ASP.Net 2.0 (comes built in for 3.5). If you haven't installed the MS Ajax Extensions on the machine where you are running this site you'll have the kind of error you've posted.

Resources