当前位置: 首页 > 知识库问答 >
问题:

无法加载文件或程序集'System.Web.WebPages.Razor, 版本=2.0.0.0, win8

姜建德
2023-03-14

在 win7 上,我的应用程序工作正常。但是当我尝试在win8上运行它时,我收到一个错误。

无法加载文件或程序集“系统.Web.WebPages.Razor,版本=2.0.0.0

System.Web.WebPages.Razor.dll 在发布期间是本地复制的。如果这很重要,我不久前从 mvc4 迁移到 mvc5。

堆栈跟踪:

[FileLoadException: 无法加载文件或程序集 'System.Web.WebPages.Razor, version=2.0.0.0, culture=neutral, PublicKeyToken=31bf3856ad364e35' lub jednej z jego zależności.Zlokalizowana definicja manifestu zestawu nie odpowiada odwołaniu do zestawu.(Wyjątek od HRESULT: 0x80131040)]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() 0

[InvalidOperationException:Metoda Start w type Microsoft。Web .网页. oauth . pre applications start code,wywoywana na etapie initializacji przed uruchomienem aplikaczi,ZG osia wyjątek;尼·można·扎多瓦·普利库·卢布·泽斯塔武系统。Web .网页. Razor,Version=2.0.0.0,Culture=neutral,public key token = 31bf 3856 ad 364 e 35 ' lub jednej z jego zależności.兹洛卡里佐瓦纳明确表示,阿牛不会放弃。(Wyjątek od HRESULT: 0x80131040)。]
系统。web . compilation . build manager . invokeporestartinitmethodscore(I collection < code > 1 methods,Func 1 setHostingEnvironmentCultures)12618627 < br >系统。web . compilation . build manager . invokeporestartinitmethods(I collection ` 1 methods)12618348 < br >系统。web . compilation . build manager . callprestarnitmethods(String prestarnitlistpath,Boolean

[HttpException(0x80004005)用法:Metoda Start键入Microsoft.Web.WebPages.OAuth。预应用程序启动代码,wywoływana na etapie inicjalizacji przed uruchomieniem aplikacji,zg \322;osi \322 a wyjątek;komunikat o bł281; dzie:Nie można za \322 adowaćpliku lub zestawu'系统.网站.网页。剃刀,版本=2.0.0.0,文化=中性,PublicKeyToken=31bf3856ad364e35'lub jednej z jego zależności。Zlokalizowana的定义是《宣言》。(Wyjątek od HRESULT:0x80131040)]
System.Web.HttpRuntime。FirstRequestInit(HttpContext上下文)12617668 System.Web.HttpRuntime。EnsureFirstRequestInit(HttpContext上下文)159 System.Web.HttpRuntime。ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文)12457285

根网络配置

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <section name="aprSection" type="APRLibrary.Configuration.APRWebSectionWithBaseLogin, APRLibrary" />
  </configSections>
  <aprSection configSource="APRTeam.config" />
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="true" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
  </appSettings>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5.1"/>
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5.1">
      <assemblies>
        <add assembly="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5" maxQueryStringLength="6048" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <machineKey compatibilityMode="Framework45" />
    <customErrors mode="Off" defaultRedirect="~/Error.cshtml">
      <error statusCode="500" redirect="~/Error.cshtml"/>
      <error statusCode="403" redirect="~/error?status=403"/>
      <error statusCode="404" redirect="~/error?status=404"/>
    </customErrors>
    <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" />
        <add namespace="Kendo.Mvc.UI" />
        <add namespace="APRTeamGrafikMVC4.Code.Helpers" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
    <security>
      <requestFiltering>
        <requestLimits maxQueryString="6048" />
      </requestFiltering>
    </security>
  </system.webServer>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
  </entityFramework>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

查看web.config

<?xml version="1.0"?>

<configuration>
  <configSections>
    <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
      <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    </sectionGroup>
  </configSections>

  <system.web.webPages.razor>
    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
      <namespaces>
        <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.Optimization" />
        <add namespace="Kendo.Mvc.UI" />
      </namespaces>
    </pages>
  </system.web.webPages.razor>

  <appSettings>
    <add key="webpages:Enabled" value="false" />
  </appSettings>

  <system.web>
    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
    </httpHandlers>

    <!--
        Enabling request validation in view pages would cause validation to occur
        after the input has already been processed by the controller. By default
        MVC performs request validation before a controller processes the input.
        To change this behavior apply the ValidateInputAttribute to a
        controller or action.
    -->
    <pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
      <controls>
        <add assembly="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

    <handlers>
      <remove name="BlockViewHandler" />
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
    </handlers>
  </system.webServer>
</configuration>

共有2个答案

龙德海
2023-03-14

实际上,当您更新NuGet包或任何东西时,问题就出现了。由于更新发生在package/dll中,相应的更新版本应包含在web配置中。不幸的是,它没有反映在导致.dll文件版本和导致上述错误的web配置版本冲突的web配置上。

解决方案:

步骤1:转到项目解决方案资源管理器-

步骤2:右键单击-

步骤3:在属性中,您将找到版本:X.X.X.X(3.0.0.0或2.0.0.0)此版本是项目中加载的实际版本。

步骤4:现在,转到Web.config文件(Views文件夹中的Web config)找到系统。Web .网页. Razor,版本=X.X.X.X行。然后,将版本更改为您在步骤3的引用属性中找到的版本号。

现在,运行代码,问题应该会消失。

张砚
2023-03-14

问题解决了。

我更新了

Microsoft.Web.WebPages.OAuth

谢谢你的帮助

 类似资料:
  • 问题内容: 我正在使用c#和数据库MySQL开发桌面应用程序。当我在计算机上安装其安装程序时,它可以正常工作,但是当我在其他计算机上安装它的安装程序时,尝试访问数据库时会出现以下异常。我用来与MySQL通信。 无法加载文件或程序集“ MySql.Data,版本= 6.2.2.0,区域性=中性,PublicKeyToken = c5687fc88969c44d”或其依赖项之一。该系统找不到指定的文件

  • 问题内容: 我完全不知所措-我仍然什至没有真正理解的地方遇到超级奇怪的问题…我正在运行Entity Framework 4.1,MySql 5.xx和MySql Connector为6.4.4版-一切正常但是在本地,只要我上传到服务器,就会收到: 我很困惑,我很肯定我在Bin目录中有MySql 6.4.4 dll,我的Web.config也对版本6.3.6进行了零引用- 我已经在整个项目中(使用全

  • 问题内容: 更新到新软件包Microsoft.EntityFrameworkCore.SqlServer 1.1.2之后,尝试创建DBContext时出现错误: 发生System.IO.FileLoadException HResult = 0x80131040 消息=无法加载文件或程序集’Microsoft.Extensions.DependencyInjection.Abstractions,

  • 我使用 ASP.NET MVC3。NET4 框架。我的项目正在本地工作,但我将文件发送到服务器并且在那里不起作用。在我的服务器文件中现在是v2。如果我将 v2 文件发送到服务器,我会得到 无法加载文件或程序集“System.Web.WebPages”。剃刀,版本=1.0.0.0,。。。 错误

  • 我正在尝试将一个项目从MVC 4/EF 5升级到MVC 5/EF 6。我将框架从4.5更新到4.5.1,然后从Nuget更新了解决方案MVC(4.0.30506.0到5.1.1)和EntityFramework(5到6.1.1)。这引入了Razor依赖项(2.0.30506.0到3.1.1)和WebPages(2.0.30506.0到3.1.1)。我编辑了Project and Views文件夹w

  • 我在ASP.NET中有一个WebApplication项目和一个实体项目(构建为DLL)。 如果我在调试模式下构建DLL,那么我的WebApp将成功加载程序集。但是当我在发布模式下构建DLL时,我的WebApp无法加载程序集。 未能加载文件或程序集“MyLibs,Version=1.0.0.0,Culture=Neutrative,PublicKeyToken=Null”或其依赖项之一。试图加载格