[英]Need help with NHibernate assembly version issue. Error with loading the correct assembly version
注意我關閉了本地化的其他票證。
所以我遇到了一個問題,就像我看到其他海報在使用NuGet安裝FluentNhibernate之后產生的:
錯誤
Could not load file or assembly 'NHibernate, Version=3.0.0.2001, 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)
我在stackOverflow答案和其他博客上看到了答案是:
Add-BindingRedirect
但是,這還沒有解決我的問題,運行該命令的所有結果是:
PM> Add-BindingRedirect
Name OldVersion NewVersion
---- ---------- ----------
NHibernate 0.0.0.0-3.0.0.4000 3.0.0.4000
當我從NuGet安裝Fluent Nhibernate時,它說它的依賴是Nhibernate 3.0.0.2001,但是它安裝了Nhibernate 3.0.0.4000
我究竟做錯了什么?
我無法評論NuGet的具體問題,但您應該能夠通過向app.config或web.config添加程序集綁定重定向來解決錯誤。
您可能想要檢查公鑰是否正確。
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Nhibernate" publicKeyToken="aa95f207798dfdb4"/>
<bindingRedirect oldVersion="3.0.0.2001" newVersion="3.0.0.4000"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
這應該將2001年的所有請求重定向到4000
我不知道你有多少網絡項目,哪個是你的開始項目設置,是基本的,但我的測試方法遇到了同樣的問題,我發現我的測試項目的app.config沒有綁定重定向。
在我的例子中,Add-BindingRedirect命令生成這樣的東西
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.4000" newVersion="3.0.0.4000" />
</dependentAssembly>
這解決了我的問題,我希望這會有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.