简体   繁体   English

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

[英]Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, win8

On win7 my application work properly. 在win7上,我的应用程序可以正常工作。 But when I try run this on win8 I get an error. 但是,当我尝试在win8上运行此命令时,出现错误。

Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0 无法加载文件或程序集'System.Web.WebPages.Razor,版本= 2.0.0.0

System.Web.WebPages.Razor.dll is copy local during publish. System.Web.WebPages.Razor.dll在发布期间是本地复制。 If it is important, I migrate from mvc4 to mvc5 a while time ago. 如果重要的话,前一段时间我从mvc4迁移到mvc5。

Stack Trace: 堆栈跟踪:

[FileLoadException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' lub jednej z jego zależności. [FileLoadException:无法加载文件或程序集'System.Web.WebPages.Razor,版本= 2.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35'。 Zlokalizowana definicja manifestu zestawu nie odpowiada odwołaniu do zestawu. Zlokalizowana definicja manifestu zestawu nie odpowiadaodwołaniudo zestawu。 (Wyjątek od HRESULT: 0x80131040)] (Wyjątekod HRESULT:0x80131040)
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start() +0 Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start()+0

[InvalidOperationException: Metoda Start w typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode, wywoływana na etapie inicjalizacji przed uruchomieniem aplikacji, zgłosiła wyjątek; [InvalidOperationException:Metoda Start w typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływanana etapie inicjalizacji prured uruchomieniem aplikacji,zgłosiławyjątek; komunikat o błędzie: Nie można załadować pliku lub zestawu 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' lub jednej z jego zależności. 信息来源:Niemożnazaładowaćpliku lub zestawu'System.Web.WebPages.Razor,版本= 2.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35',显示为“ jednej z jegozależności”。 Zlokalizowana definicja manifestu zestawu nie odpowiada odwołaniu do zestawu. Zlokalizowana definicja manifestu zestawu nie odpowiadaodwołaniudo zestawu。 (Wyjątek od HRESULT: 0x80131040).] (Wyjątekod HRESULT:0x80131040)。
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection 1 methods, Func 1 setHostingEnvironmentCultures) +12618627 System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection 1 methods, Func 1 setHostingEnvironmentCultures)+12618627
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12618348 System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1方法)+12618348
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +280 System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串preStartInitListPath,布尔值和isRefAssemblyLoaded)+280
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172 System.Web.Compilation.BuildManager.ExecutePreAppStart()+172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParametershostingParameters,PolicyLevel policyLevel,Exception appDomainCreationException)+1151

[HttpException (0x80004005): Metoda Start w typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode, wywoływana na etapie inicjalizacji przed uruchomieniem aplikacji, zgłosiła wyjątek; [HttpException(0x80004005):从Microsoft.Web.WebPages.OAuth.PreApplicationStartCode开始的方法启动,立即开始使用uruchomieniem aplikacji,然后再通过; komunikat o błędzie: Nie można załadować pliku lub zestawu 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' lub jednej z jego zależności. 信息来源:Niemożnazaładowaćpliku lub zestawu'System.Web.WebPages.Razor,版本= 2.0.0.0,文化=中性,PublicKeyToken = 31bf3856ad364e35',显示为“ jednej z jegozależności”。 Zlokalizowana definicja manifestu zestawu nie odpowiada odwołaniu do zestawu. Zlokalizowana definicja manifestu zestawu nie odpowiadaodwołaniudo zestawu。 (Wyjątek od HRESULT: 0x80131040).] (Wyjątekod HRESULT:0x80131040)。
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12617668 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12457285 System.Web.HttpRuntime.FirstRequestInit(HttpContext上下文)+12617668 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext上下文)+159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext上下文)+12457285

root Web.config 根Web.config

<?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>

Views web.config 查看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>

Problem solved. 问题解决了。

I update 我更新

Microsoft.Web.WebPages.OAuth

Thanks for any help 谢谢你的帮助

Actually, the problem occurred when you update NuGet packages or anything. 实际上,当您更新 NuGet软件包或其他任何东西时,都会发生此问题。 Since the update happens in package/dll respective version updated should be included in web config . 由于更新发生在package / dll中,因此应将相应的更新版本包含在web config中 Unfortunately, it is not reflected on the web config resulting conflict in the .dll file version and web config version resulting above error. 不幸的是,它没有反映在导致上述错误的.dll文件版本和Web配置版本导致的Web配置冲突中。

Solution: 解:

Step 1: Go to Project Solution Explorer-> Reference -> System.Web.WebPages.Razor(Any reference throwing error) 步骤1:转到项目解决方案资源管理器->参考-> System.Web.WebPages.Razor(任何参考抛出错误)

Step 2: Right-click-> properties 步骤2: 右键单击->属性

Step 3: In properties, you will find Version: XXXX (3.0.0.0 or 2.0.0.0) This version is the actual version loaded in the project. 步骤3:在属性中,您将找到Version版本):XXXX (3.0.0.0或2.0.0.0)。此版本是项目中加载的实际版本。

Step 4: Now, go to Web.config file (Web config in Views folder) find the System.Web.WebPages.Razor, Version=XXXX line. 步骤4:现在,转到Web.config文件(“视图”文件夹中的Web配置),找到System.Web.WebPages.Razor,Version = XXXX行。 Then, change the Version to Version number which you found in reference properties in step 3 . 然后,将“版本”更改为在步骤3中的参考属性中找到的“版本号”。

Now, run the code the problem should go away. 现在,运行代码即可解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:“无法加载文件或程序集System.Web.WebPages.Razor” - Error: “Could not load file or assembly System.Web.WebPages.Razor” 运行时错误:无法加载文件或程序集“System.Web.WebPages.Razor,版本=3.0.0.0” - Runtime error: Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 无法加载文件或程序集 'System.Web.WebPages.Razor,版本 = 3.0.0.0 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=3.0.0.0 无法加载文件或程序集 'System.Web.WebPages.Razor,版本 = 1.0.0.0 或其依赖项之一。 该系统找不到指定的文件 - Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0 or one of its dependencies. The system cannot find the file specified 在Kentico 8.2升级到9站点后,抛出System.Web.WebPages.Razor版本,Version = 2.0.0.0,例外 - After Kentico Upgrade 8.2 to to 9 site throwing System.Web.WebPages.Razor version , Version=2.0.0.0, exception 为什么未加载“ System.Web.WebPages.Razor”程序集? - Why is the 'System.Web.WebPages.Razor' assembly not loading? 无法加载文件或程序集“System.Web.Razor,版本=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35” - Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' 无法加载文件或程序集&#39;System.Web.Razor,版本= 2.0.0.0,区域性=中性,PublicKeyToken = 31bf3856ad364e35&#39;或其依赖项之一 - Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies 尝试引用较新版本的System.Web.WebPages.Razor的MVC4应用程序的问题 - Problems with an MVC4 application trying to reference a newer version of System.Web.WebPages.Razor 无法加载文件或程序集 System.Web.WebPages.Deployment - Could not load file or assembly System.Web.WebPages.Deployment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM