类型';System.Web.Mvc.MvcWebRazorHostFactory';不能用于返回类型
本文关键字:用于 返回类型 不能 Web System 类型 Mvc MvcWebRazorHostFactory | 更新日期: 2023-09-27 18:27:51
我有一个用MVC 3开发的网站,试图用Visual Studio 2012打开,它更新了项目并尝试运行该项目,它给出了错误:
The expression of type 'System.Web.Mvc.MvcWebRazorHostFactory' can not be used for return type 'System.Web.WebPages.Razor.WebRazorHostFactory'
System.Web.Mvc将DLL更新为4.0.0.1版本。
Web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<add name="Main" connectionString="Data Source=sacteste;Persist Security Info=True;User ID=automa;Password=auto2020;Unicode=True"
providerName="System.Data.OracleClient"/>
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
<add key="AssuntoEmailNotas" value="Nota fiscal emitida"/>
<add key="TemplateEmailNotas" value="C:'DotNet'PIF'GestaoNFSe'templateNFSe.cshtml"/>
<add key="TemplateEmailCobranca" value="C:'DotNet'PIF'GestaoNFSe'templateCartaCobranca.cshtml"/>
<add key="EmailFromEndereco" value="desenvolvimento@megasul.com.br"/>
<add key="EmailFromNome" value="Megasul"/>
<add key="ChaveCriptografia" value="_nfse_megasul#1234"/>
<!-- alterar a chave invalida todos os e-mails já enviados! -->
<add key="DiretorioLicencasCobreBem" value="C:'CobreBemX'"/>
<add key="enableSimpleMembership" value="false"/>
<add key="autoFormsAuthentication" value="false"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Helpers, Version=1.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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880"/>
</authentication>
<membership defaultProvider="MegaMembershipProvider">
<providers>
<clear/>
<add name="MegaMembershipProvider" applicationName="WebRAT" type="MegaControls.Membership.MegaMembershipProvider" connectionStringName="Main"
enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" minRequiredNonAlphanumericCharacters="0"
maxInvalidPasswordAttempts="10" minRequiredPasswordLength="1" writeExceptionsToEventLog="false" passwordFormat="Clear"/>
<!--119746-->
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers"/>
<add namespace="System.Web.Mvc"/>
<add namespace="System.Web.Mvc.Ajax"/>
<add namespace="System.Web.Mvc.Html"/>
<add namespace="System.Web.Routing"/>
<add namespace="System.Web.WebPages"/>
</namespaces>
</pages>
<customErrors mode="Off"/>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.net>
<mailSettings>
<smtp deliveryMethod="Network">
<network host="192.168.0.201" defaultCredentials="false" userName="jani" password="jani"></network>
</smtp>
</mailSettings>
</system.net>
<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.1" newVersion="4.0.0.1"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
打开Views文件夹中的Web.config文件,并从2015年10月26日起将factorytype版本更改为5.0.0.0。
即
来自
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
至
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />