同时运行两个版本的MongoDB程序集

问题描述 投票:1回答:1

所有,

我的项目 - (VS 2010 / .NET 4 / ASP.NET应用程序,我的Web应用程序作为Sitefinity应用程序存在于Sitefinity中)

我有两个版本的MongoDB程序集。我想在我的Web应用程序中并排运行这些。这是我的设置:

\bin\AuxFiles\[1.8.3.9] assemblies

\bin\[1.4.x.x] assemblies

网络配置:

<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>

应用程序启动时,默认情况下会加载1.4.x.x程序集。当我转到使用1.8.3.9版程序集的页面时,我收到一个错误:

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

更新1:

我试图将我的新1.8.xx程序集从MongoDB.Driver.dll重命名为MongoDB.Driver.exe,因此文件可以在同一目录下共存(较旧的程序集具有扩展名.dll,新版本的程序集具有扩展名.exe)但是加载程序似乎没有提取集会。我的理解是,加载器总是首先尝试.dlls,然后尝试.exes秒。我有点不解。


更新2:

我已经创建了一个控制台应用程序w /我的双重引用和你在这里看到的应用程序配置条目完全相同的设置 - 并且应用程序工作,它执行2个版本的Mongo dll。问题是,为什么这个设置在我的Web应用程序中不起作用?我的目录错了吗?如果你看下面的探测程序集,它永远不会检查我的AuxFiles目录,它似乎忽略了我在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.

更新3:

发现了这个问题,但我不确定这个解决方案的细节。 web.config文件具有'configuration'根元素w /以下命名空间声明 - 'xmlns=http://schemas.microsoft.com/.NetConfiguration/v2.0'

根元素很好,但指定的命名空间导致我的'runtime'元素被忽略。从配置元素中删除命名空间可以修复所有问题。

asp.net .net .net-assembly
1个回答
1
投票

发现问题:

web.config文件中的“configuration”根元素包含以下名称空间声明 - “xmlns = http://schemas.microsoft.com/.NetConfiguration/v2.0”。从配置元素中删除命名空间可以修复所有问题。

为什么ns?它更像是VS中的任何错误,并且实际上没有任何真正的目的,但是搞乱了你的智能感知,在我的情况下是运行时配置。了解更多信息:http://weblogs.asp.net/scottgu/archive/2005/12/02/432077.aspx

© www.soinside.com 2019 - 2024. All rights reserved.