我刚刚重新启动了一个使用 NHibernate 的项目。我上次使用该项目时运行良好,但现在出现以下错误。
System.IO.FileLoadException: Could not load file or assembly 'Iesi.Collections, Version=1.0.0.3, 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) at NHibernate.Cfg.Configuration.Reset() at NHibernate.Cfg.Configuration..ctor(SettingsFactory settingsFactory) at NHibernate.Cfg.Configuration..ctor() at Luther.Dao.Repositories.Session.NHibernateHelper..cctor() in NHibernateHelper.cs: line 18
我注意到当前对 iesi.dll 的引用位于 1.0.1.0。 让它重新启动并运行的最佳方法是什么?尝试找到合适版本的dll或整理 list 文件?
最佳答案
自上次运行此应用程序以来,您是否更新了项目中的某个程序集? NHibernate 似乎是针对版本 1.0.0.3 构建的,而您当前拥有的是 1.0.1.0。
您应该能够使用 BindingRedirect App.config(或 web.config,视情况而定)中的元素指示 .Net Framework 满足不同版本的依赖关系。类似的东西
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Iesi.Collections"
publicKeyToken="aa95f207798dfdb4"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.3"
newVersion="1.0.1.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
关于.net - c# dll绑定(bind)到不同版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2672253/