问题 无法加载文件或程序集System.Web.WebPages.Deployment


我正在开发系统网页,突然出现这个错误:

Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

我已经验证了我的xml文件配置,一切都很好看。 这是堆栈跟踪:

[FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17
   System.Reflection.Assembly.Load(String assemblyString) +35
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12480704
   System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +202
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +331
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12601936
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12441597

10597
2018-06-04 14:44


起源

你是从项目中引用它吗? - Matias Cicero


答案:


请尝试以下步骤。

  1. 检查版本 System.Web.Webpages 在你的参考文献中。说你的版本是= X.X.X.X

2.在Webconfig中

a。首先添加组件

<assemblies>        
    <add assembly="System.Web.WebPages, Version=X.X.X.X, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  </assemblies>

b。将程序集绑定到运行时

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-X.X.X.X" newVersion="X.X.X.X"/>
  </dependentAssembly>        
</assemblyBinding>

3.确保您添加了正确的密钥

<appSettings>
    <add key="webpages:Version" value="X.X.X.X"/>
</appSettings>

这对我有用。希望它也能帮到你。


6
2017-11-08 20:33



我有这个条目仍然有问题。像User37 ...写道,人们也需要System.Web.WebPages.Deployment的一个条目,这很奇怪 - publicKeyToken是相同的。对我来说,问题出现在清除全局程序集缓存之后,这很糟糕地搞砸了我的.net框架安装。 - Jan Bühler


我在下面添加了一行解决了这个问题 web.config 项目...... 

在我在MANAGE NUGET“Microsoft.AspNet.Mvc / 5.1.2”,“Microsoft ASP.NET Web Pages / 3.1.2”中标记之前,我尝试了一切,但没有任何作用(真的!!卸载VS并阅读了很多文章)

<dependentAssembly>
   <assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31bf3856ad364e35" />
   <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>

祝你好运


4
2018-06-14 13:49



伟大的好工作,大+1 - Sender


在我的情况下,这是由于我的笔记本电脑崩溃重启导致的程序集损坏。

要解决此问题,请按照以下步骤操作

  1. 清除项目的以下文件夹中的所有文件,或者只需单击清洁项目和清洁解决方案即可

    • \ BIN
    • \ OBJ
  2. 清理Appdata临时文件夹 对于我的Win 7机器,它位于Windows 7中的C:\ Users \ your_username \ AppData \ Local \ Temp \ Temporary ASP.NET Files

希望这可以帮助!


1
2018-06-19 10:06





我通常做的是转到编译代码的机器,然后转到dos提示符并输入

C:> dir System.Web.WebPages.Depl* /s 

通常可能有几个

c:/windows/Microsoft.Net/assembly/GAG_MSIL/System.web.WebPage/v....../

检查日期并确保与之相同 System.Web.WebPages.dll  将其复制到目标计算机所在的bin中。这应该可以解决问题。


0
2018-04-21 14:47





将此代码复制到“配置”中 Web.config文件,那会做到的

  <runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages.Deployment" publicKeyToken="31BF3856AD364E35" culture="neutral"/>
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0"/>
  </dependentAssembly>
</assemblyBinding></runtime>

0
2018-03-26 09:45



“oldVersion”是一个很大的范围,“newVersion”是你的[System.Web.WebPages.Deployment.dll]版本; [dll]版本你可以在“C:\ Program Files(x86)\ Microsoft ASP中获得它。 NET \ ASP.NET网页\ v2.0 \ Assemblies“ - Vagus