![](/img/trans.png)
[英]Suddenly my web-api project can't find references to System.Web.Mvc, compiles fine but runtime error
[英]Find cause of multiple System.Web.Mvc references
使用dotPeek檢查Web項目主程序集的引用,我看到:
System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Visual Studio中的項目引用僅顯示版本5.2.3.0。 我還搜索了引用項目的.csproj文件。
Manage NuGet Packages僅顯示Microsoft.AspNet.Mvc v5.2.3。
搜索packages
文件夾僅在Microsoft.AspNet.Mvc.5.2.3\\lib\\net45
下找到Microsoft.AspNet.Mvc.5.2.3\\lib\\net45
。
gacutil /l System.Web.Mvc
顯示版本3.0.0.0和4.0.0.0。
我已經通過dotPeek的References Hierarchy瀏覽了其他參考文獻,但沒有找到舊版本。
根據答復,我檢查了Web.config。 這已經存在:
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
我還檢查了其他Web.configs是否存在版本沖突。
另外,我嘗試在System.Web.Mvc參考屬性中將“特定版本”設置為True。 這沒什么區別。
是否需要多個版本? 如果沒有,我如何找到並刪除舊版本的源代碼?
嘗試將其添加到您的web.config
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
基本上,這將測試您的應用程序是否對應用程序中引用的System.Web.MVC的任何版本(從1-5.2.3開始)使用5.2.3.0。 您很有可能仍在參考中尋找特定版本的5.0。 使用JSON.net一直使我無聊。
從引用中刪除多個現有的dependency
。 之后,添加要保留在項目中的reference
。
從屬性窗口中,您可以看到當前dependency
的版本。 從中檢查該版本,然后在web.config
文件中設置版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.