Asp.net-Mvc-4

GAC 問題無法在 IIS 上託管應用程序

  • March 10, 2016

在 IIS 7.5 上執行我的 MVC 4 應用程序時出現以下錯誤。但是,當我通過 Visual Studio 執行此應用程序時,它不會引發錯誤。此外,我嘗試在我的 Uni 電腦上託管應用程序,它似乎工作正常。

 Compiler Error Message: CS0433: The type 'System.Web.Mvc.WebViewPage<TModel>' exists in   both      'c:\windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' and 'c:\windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll'

這是我的 web.config 文件中引用的程序集

    <system.web>
        <compilation targetFramework="4.0">
           <assemblies>
               <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral,     PublicKeyToken=31BF3856AD364E35" />              
               <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
               <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />               
               <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
           </assemblies>
       </compilation>      
</system.web>

System.Web.Mvc在應用程序 bin 文件夾中有程序集嗎?如果是這樣,請嘗試刪除

<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 

來自 web.config。

它沒有解決我的問題,但事實證明,將版本更改為 3.0.0.1 確實:

<add assembly="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

和:

<runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" /> </dependentAssembly> </assemblyBinding> </runtime> <applicationSettings>

引用自:https://stackoverflow.com/questions/18845374