我有一个在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。
<?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>
答案 0 :(得分:2)
打开位于Views文件夹中的Web.config文件,并在2015年10月26日之前将factorytype版本更改为5.0.0.0。
即
这
fmt.Printf("address in SetMember: %p\n", &h)
要
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />