nhibernate - Visual Studio .Net 中显示的 dll 版本不反射(reflect)引用的 dll 文件/产品版本

标签 nhibernate c#-4.0 sharp-architecture

我有一个控制台应用程序 c# 项目,它依赖于 NHibernate 3.3.2 和 ShapArch.NHibernate 2.0.4.628,它已经用 NHibernate 3.3.1 编译(据我所知 - 我可能错了,但是当我创建了一个 2.0.4它通过 Nuget 下载了 NH 3.3.1 的 SharpArch 项目)。

为什么当引用的 dll 为 3.3.2.4000 时,Visual Studio 将 NHibernate 显示为版本 3.3.1.4000?对于所有引用,Specific Version 属性设置为 false。 SharpArch 的版本出现在 VS 2.0.0.0 中,而不是文件/产品版本的 2.0.4。

在应用程序配置中,我有:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-3.3.1.4000" newVersion="3.3.2.4000" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

该应用程序无法加载:
System.IO.FileLoadException was unhandled
  Message=Could not load file or assembly 'NHibernate, Version=3.3.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=MyApp.ResourcesGenerator
  FileName=NHibernate, Version=3.3.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
  FusionLog=""
  StackTrace:
       at MyApp.ResourcesGenerator.Program.InitializeNHibernateSession()
       at SharpArch.NHibernate.NHibernateInitializer.InitializeNHibernateOnce(Action initMethod) in d:\Builds\SharpArch2\Solutions\SharpArch.NHibernate\NHibernateInitializer.cs:line 54
       at MyApp.ResourcesGenerator.Program.Initialize() in C:\projects\tc\Trunk\Source_LibsUpgrade\Applications\PerformanceManagement\MyApp.ResourcesGenerator\Program.cs:line 149
       at MyApp.ResourcesGenerator.Program.Main(String[] args) in C:\projects\tc\Trunk\Source_LibsUpgrade\Applications\PerformanceManagement\MyApp.ResourcesGenerator\Program.cs:line 31
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileLoadException
       Message=Could not load file or assembly 'NHibernate, Version=3.3.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
       FileName=NHibernate, Version=3.3.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4  

我什至不确定为什么在使用 3.3.1 编译了清晰的架构时它会尝试加载 3.3.0.4000。

最佳答案

NHibernate 3.3.2.GA 有一个 文件 3.3.2.4000 的版本,但 组装 版本仍然是 3.3.1.4000。这样做是为了在不需要绑定(bind)重定向的情况下升级 NHibernate。 NHibernate 的所有 future 小版本升级也将遵循这种模式。

因此,您的解决方案就是删除绑定(bind)重定向。

这里令人困惑的部分是 Windows 资源管理器仅显示文件和产品版本,而 Visual Studio 仅显示程序集版本。

关于nhibernate - Visual Studio .Net 中显示的 dll 版本不反射(reflect)引用的 dll 文件/产品版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13576604/

相关文章:

NHibernate 将字符串参数转换为 nvarchar 而不是 varchar。我怎样才能阻止这个?

postgresql - 在postgresql中获取序列的下一个值

.net - 在WPF中使用OpenFileDialog时没有文件的文件夹路径?

nhibernate - SQL Azure 联合与 S#arp 架构

c# - NHibernate 哪个缓存用于 WinForms 应用程序

c# - xaml 中带有 TreeViewItems 的 ListView

c# - 局部 View 每 5 秒在服务器上调用一个方法 - 页面本身不需要更改

asp.net-mvc - IIS 上的 ASP.NET MVC3 和 Windows Auth 不断重定向到/Account/Login

c# - 覆盖长文本字符串的流利 NHibernate nvarchar(MAX) 而不是 nvarchar(255)

hibernate - nHibernate.Search 使用 nHibernate v2