2016-03-09 63 views
3

我在我的項目中使用PostSharp 4.2.22.0和Owin 3.0.1。文章檔案OWIN Version Mismatch

我編譯時出現以下錯誤:

Unhandled exception (4.2.22.0, postsharp-net40-x86-srv.exe, CLR
4.0.30319.394271, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'microsoft.owin.security, version=2.1.0.0, culture=neutral, publickeytoken=31bf3856ad364e35'. [Version mismatch]

但沒有PostSharp有Owin辦?爲什麼Owin版本對PostSharp很重要,這是兩個完全不同的軟件包。

+0

的可能的複製[與PostSharp問題找不到system.web.mvc,版本裝配= 3.0.0.0當沒有項目中引用它(HTTP:/ /stackoverflow.com/questions/26146922/issue-with-postsharp-cannot-find-assembly-for-system-web-mvc-version-3-0-0-wh) –

回答

6

此錯誤通常出現在項目中,該項目在web.config文件中引用帶有綁定重定向的程序集的舊版本。我想你有這樣的事情在你的web.config:

<dependentAssembly> 
    <assemblyIdentity name="microsoft.owin.security" publicKeyToken="31bf3856ad364e35" culture="neutral"/> 
    <bindingRedirect oldVersion="0.0.0.0-3.0.1.0" newVersion="3.0.1.0"/> 
</dependentAssembly> 

PostSharp默認情況下不處理的web.config /的app.config文件。通過將PostSharpHostConfigurationFile MSBuild屬性設置爲web.config文件的路徑,可以強制PostSharp加載綁定重定向。

您可以通過添加這些行到您的csproj文件做到這一點:

<PropertyGroup> 
    <PostSharpHostConfigurationFile>web.config</PostSharpHostConfigurationFile> 
</PropertyGroup> 

此不便應該是已經固定在PostSharp 4.3沒有設置PostSharpHostConfigurationFile財產。但目前4.3還不是一個穩定版本。

編輯:代碼更新(缺少結束「>」)

+0

非常感謝你,解決了問題 – Pinzi