gpt4 book ai didi

c# - 类型 'System.Web.Mvc.MvcWebRazorHostFactory' 的表达式不能用于返回类型 'System.Web.WebPages.Razor.WebRazorHostFactory'

转载 作者:太空宇宙 更新时间:2023-11-03 10:38:21 29 4
gpt4 key购买 nike

我有一个用 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 文件,并将 factorytype 版本更改为截至 2015 年 10 月 26 日的 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" />

关于c# - 类型 'System.Web.Mvc.MvcWebRazorHostFactory' 的表达式不能用于返回类型 'System.Web.WebPages.Razor.WebRazorHostFactory',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26546943/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com