Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法加载文件或程序集System.Web.WebPages.Razor,版本=2.0.0.0,win8_C#_Asp.net_Asp.net Mvc_Razor - Fatal编程技术网

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

C# 无法加载文件或程序集System.Web.WebPages.Razor,版本=2.0.0.0,win8,c#,asp.net,asp.net-mvc,razor,C#,Asp.net,Asp.net Mvc,Razor,在win7上,我的应用程序工作正常。但是当我尝试在win8上运行这个时,我得到了一个错误 无法加载文件或程序集System.Web.WebPages.Razor, 版本=2.0.0.0 System.Web.WebPages.Razor.dll在发布期间是本地副本。 如果这很重要,我不久前就从mvc4迁移到了mvc5 堆栈跟踪: [FileLoadException:无法加载文件或程序集 'System.Web.WebPages.Razor,版本=2.0.0.0,文化性=中性, PublicKe

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

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

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

堆栈跟踪:

[FileLoadException:无法加载文件或程序集 'System.Web.WebPages.Razor,版本=2.0.0.0,文化性=中性, PublicKeyToken=31bf3856ad364e35'lub jednej z jego zależności。 Zlokalizovana明确的宣言 zestawu.Wyjątek od HRESULT:0x8013100] Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start+0

[无效操作例外:Metoda启动w TYPE Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływana 我认为这是一个很好的解决方案,zgłosiła wyjątek; 共青团团长奥贝兹:尼莫纳·扎阿多瓦奇·普利库·泽斯塔乌 'System.Web.WebPages.Razor,版本=2.0.0.0,文化性=中性, PublicKeyToken=31bf3856ad364e35'lub jednej z jego zależności。 Zlokalizovana明确的宣言 zestawu.Wyjątek od HRESULT:0x8013100。] System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCoreICollection1 方法,Func1设置宿主环境培养+12618627 System.Web.Compilation.BuildManager.InvokePrestartInethodsCollection`1 方法+12618348 System.Web.Compilation.BuildManager.CallPreStartInitMethodsString preStartInitListPath,布尔值&isRefAssemblyLoaded+280 System.Web.Compilation.BuildManager.ExecuteRepapStart+172 System.Web.Hosting.HostingEnvironment.InitializeApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters, PolicyLevel PolicyLevel,异常appDomainCreationException+1151

[HttpException 0x80004005:Metoda启动w类型 Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływana 我认为这是一个很好的解决方案,zgłosiła wyjątek; 共青团团长奥贝兹:尼莫纳·扎阿多瓦奇·普利库·泽斯塔乌 'System.Web.WebPages.Razor,版本=2.0.0.0,文化性=中性, PublicKeyToken=31bf3856ad364e35'lub jednej z jego zależności。 Zlokalizovana明确的宣言 zestawu.Wyjątek od HRESULT:0x8013100。] System.Web.HttpRuntime.FirstRequestInitHttpContext上下文+12617668 System.Web.HttpRuntime.EnsureRefirstrequestinitHttpContext上下文 +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivateIIS7WorkerRequest wr,HttpContext+12457285

根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>
查看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>
问题解决了

我更新

Microsoft.Web.WebPages.OAuth

感谢您的帮助实际上,问题发生在您更新NuGet软件包或任何东西时。由于更新发生在package/dll中,相应的更新版本应包含在web配置中。不幸的是,它没有反映在web配置上,从而导致.dll文件版本和web配置版本之间的冲突,从而导致上述错误

解决方案:

步骤1:转到项目解决方案资源管理器->参考->System.Web.WebPages.RazorAny参考抛出错误

步骤2:右键单击->属性

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

步骤4:现在,转到Views文件夹中的Web.config文件Web config 查找System.Web.WebPages.Razor,Version=X.X.X.X行。 然后,将版本更改为在步骤3的“引用属性”中找到的版本号


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

我有时会收到此消息,并发现如果我等待约30秒并点击“刷新”按钮,它就会消失,您是否尝试过此操作?Dll版本发生冲突。请卸载Microsoft.AspNet.Mvc并重新安装。然后重新生成项目。@JMK-刷新不起作用work@CodingDefined-我在win7上有VS,工作正常,我发布我的项目并在其他计算机上运行,win7正常,但在win8上没有。