Azure Webjob Incompatibility with NewtonSoft - json.net

I'm getting the following exception when my Azure WebJob handler starts up:
System.IO.FileLoadException was unhandled FileName=Newtonsoft.Json,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
FusionLog==== Pre-bind state information === LOG: DisplayName =
Newtonsoft.Json, Version=6.0.0.0, Culture=neutral,
PublicKeyToken=30ad4fe6b2a6aeed (Fully-specified) LOG: Appbase =
file:///C:/Programming/ConnellCampaigns/src/UploadProcessor/bin/Debug/net46/win7-x64/
LOG: Initial PrivatePath = NULL Calling assembly :
Microsoft.Azure.WebJobs.Host, Version=1.1.2.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35.
=== LOG: This bind starts in default load context. LOG: Using application configuration file:
C:\Programming\ConnellCampaigns\src\UploadProcessor\bin\Debug\net46\win7-x64\UploadProcessor.exe.Config
LOG: Using host configuration file: LOG: Using machine configuration
file from
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 6.0.0.0
redirected to 6.0.0.0. LOG: Post-policy reference: Newtonsoft.Json,
Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed LOG:
Attempting download of new URL
file:///C:/Programming/ConnellCampaigns/src/UploadProcessor/bin/Debug/net46/win7-x64/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.
HResult=-2146234304 Message=Could not load file or assembly
'Newtonsoft.Json, Version=6.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)
Source=Microsoft.Azure.WebJobs.Host StackTrace:
at Microsoft.Azure.WebJobs.Host.Protocols.PersistentQueueWriter1.<EnqueueAsync>d__0.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder1.Start[TStateMachine](TStateMachine&
stateMachine)
at Microsoft.Azure.WebJobs.Host.Protocols.PersistentQueueWriter`1.EnqueueAsync(T
message, CancellationToken cancellationToken)
at Microsoft.Azure.WebJobs.Host.Loggers.PersistentQueueLogger.LogHostStartedAsync(HostStartedMessage
message, CancellationToken cancellationToken)
at Microsoft.Azure.WebJobs.Host.Executors.JobHostContextFactory.LogHostStartedAsync(IFunctionIndex
functionIndex, HostOutputMessage hostOutputMessage,
IHostInstanceLogger logger, CancellationToken cancellationToken)
at Microsoft.Azure.WebJobs.Host.Executors.JobHostContextFactory.d__b.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.Azure.WebJobs.Host.Executors.JobHostContextFactory.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.Azure.WebJobs.JobHost.d__f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.Azure.WebJobs.JobHost.d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)
at Microsoft.Azure.WebJobs.JobHost.Start()
at Microsoft.Azure.WebJobs.JobHost.RunAndBlock()
at UploadProcessor.Program.Main(String[] args) in C:\Programming\ConnellCampaigns\src\UploadProcessor\Program.cs:line 25
InnerException:
This only happens if I specify the latest version - 9.0.1 - of NewtonSoft's JSON assembly in project.json.
I can make the error go away by specifying the last v6 issue of the library (6.0.8). But that introduces dependency warnings.
I don't understand why Microsoft.Azure.WebJobs.Host insists on an older version of the library. Its nuget page says it's compatible with any version >= 6.0.8.
How do I resolve this?

The exception trace you posted above says you have a binding redirect in your application config file:
Redirect found in application configuration file: 6.0.0.0 redirected to 6.0.0.0.
Try changing it to redirect to the assembly version you're actually using:
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
Important note: binding redirects use the Assembly Version, not the File Version. So for Json.Net 9.0.x, this would be 9.0.0.0. If you try to use the File Version as the newVersion of the redirect, the redirect will not work because it won't match the Assembly Version of the actual assembly.

Related

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

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?

Using Cloud SQL with .NET Bookshelf tutorial

I'm following the bookshelf tutorial with cloud sql:
https://cloud.google.com/dotnet/getting-started/using-cloud-sql
When running the application on my localmachine the application works fine.
When the application is deployed to Compute Engine. The server shows a runtime error which can't be read.
<customErrors mode="Off"/>
doesn't help to show the error.
When connecting thru RDP and watching the application on localhost on the Remote Desktop the following error is shown:
Server Error in '/' Application.
Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 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 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Assembly Load Trace: The following information can be helpful to determine why the assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Stack Trace:
[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
WebMatrix.WebData.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +874
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +133
System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
[HttpException (0x80004005): The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +712
I can't declare why the application gives this error since I haven't found some kind of reference in the project to the 2.0.0.0 version of Razor.
Version 3.0.0.0 of System.Web.WebPages.Razor is included as project reference.
Is it wise to downgrade to version 2 of Razor or are there other solutions?
So, there's a dependency to 2.0 version but you have 3.0 version installed on your system? In that case, you can try declaring a binding redirect from 2.0 to 3.0. Here's more information on how to declare binding redirects:
https://msdn.microsoft.com/en-us/library/7wd6ex19(v=vs.110).aspx
The total solution to solve the problem is:
Declare binding redirects https://stackoverflow.com/a/39999353/2629901 as answered by #Mete Atamel on this post
After declaring binding redirects to following error is shown:
Attempt by security transparent method 'WebMatrix.WebData.PreApplicationStartCode.Start()' to access security critical method 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport(System.String)' failed.
This can be solved by
Install-Package Microsoft.AspNet.WebHelpers with NuGet Console as mentioned in https://stackoverflow.com/a/19568376/2629901
After that the following error is shown
Could not load file or assembly 'WebMatrix.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
This can be solved by
Install-Package Microsoft.AspNet.WebPages.Data with NuGet Console as mentioned in https://stackoverflow.com/a/22587521/2629901

ASP.NET 5 RC1 -- Could not load file or assembly Newtonsoft.Json

After upgrading to Newtonsoft.Json 8.0.2, I started getting the following error on my ASP.NET 5 RC1 application, and I'm not sure how to resolve it. Under the old version we would use a BindingRedirect. How do we resolve this in the new vNEXT version of ASP.NET
System.IO.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.
File name: 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load(Stream stream)
at Microsoft.Extensions.Configuration.Json.JsonConfigurationProvider.Load()
at Microsoft.Extensions.Configuration.ConfigurationBuilder.Add(IConfigurationProvider provider)
at Microsoft.Extensions.Configuration.JsonConfigurationExtensions.AddJsonFile(IConfigurationBuilder configurationBuilder, String path, Boolean optional)
at Microsoft.AspNet.Hosting.WebApplication.Run(Type startupType, String[] args)
at Microsoft.AspNet.Server.Kestrel.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.ApplicationHost.Program.<>c__DisplayClass3_0.<ExecuteMain>b__0()
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Ok, so to fix this issue I had to remove the WRAP / Newtonsoft.Json folder. Apparently installing the new version created an entry for it in the WRAP folder. Once I removed it form there, my app runs fine again.

VS2015/DNX building Microsoft.Framework.Logging from github results in testing error

So I have my VS2015 Enterprise installed. I grab the latest Microsoft.Framework.Logging from github, load the solution and build it.
After it restores all the dependent packages it does seem to build OK but then I get this error on the test:
Starting Microsoft.Framework.TestHost [C:\Users\dan_000\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnx.exe --appbase "D:\code\DanForks\Logging\test\Microsoft.Framework.Logging.Test" Microsoft.Framework.ApplicationHost --port 1388 Microsoft.Framework.TestHost --port 5651]
System.InvalidOperationException: Unable to load application or execute command 'Microsoft.Framework.TestHost'. Available commands: run, test.
at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundException(DefaultHost host, String applicationName, Exception innerException)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at dnx.host.Bootstrapper.RunAsync(List``1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
When I run the same command in a command prompt with DNX_TRACE=1, I get:
Test" Microsoft.Framework.ApplicationHost --port 1388 test --port 1462
The servicing index file at: C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt does not exist or could not be opened.
Loaded module: dnx.clr.dll
Found export: CallApplicationMain
Information: [DomainManager] Using Desktop CLR v4.5.1
Information: [Bootstrapper] Runtime Framework: DNX,Version=v4.5.1
Information: [DefaultHost]: Project path: D:\code\DanForks\Logging\test\Microsoft.Framework.Logging.Test
Information: [DefaultHost]: Project root: D:\code\DanForks\Logging
Information: [DefaultHost]: Packages path: C:\Users\dan_000\.dnx\packages
Information: [DependencyWalker]: Walking dependency graph for 'Microsoft.Framework.Logging.Test DNX,Version=v4.5.1'.
Information: [WalkContext]: Graph walk stage 1 took in 28ms
Information: [DependencyWalker]: Graph walk took 31ms.
Information: [ServicingIndex]: Servicing index not found at C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt
Information: [WalkContext]: Populate took 15ms
Information: [DependencyWalker]: Resolved dependencies for Microsoft.Framework.Logging.Test in 49ms
Information: [LoaderContainer]: Load name=xunit.runner.aspnet
Information: [NuGetAssemblyLoader]: Loaded name=xunit.runner.aspnet in 5ms
Information: [LoaderContainer]: Load name=xunit.runner.utility.AspNet, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null
Information: [NuGetAssemblyLoader]: Loaded name=xunit.runner.utility.AspNet, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null in 1ms
Information: [LoaderContainer]: Load name=xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
Information: [NuGetAssemblyLoader]: Loaded name=xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c in 1ms
Information: [LoaderContainer]: Load name=Microsoft.Dnx.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Information: [NuGetAssemblyLoader]: Loaded name=Microsoft.Dnx.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null in 1ms
System.NullReferenceException: Object reference not set to an instance of an object.
at Xunit.Runner.AspNet.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at dnx.host.Bootstrapper.RunAsync(List``1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
My solution DNX versions for all the projects is 1.0.0-beta6.
I'm not extremely familiar with how the xunit stuff all works. I figure I have some sort of runtime mismatch somewhere?
I think one of the dependency changes which breaks xunit runner. I think you have to wait xunit update reference or code to address the changes. Also, different version of xunit target different dnx as well. Make sure update xunit to xUnit.net 2.1 Beta 4
http://xunit.github.io/docs/getting-started-dnx.html

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

Resources