无法加载文件或程序集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.
我已经validation了我的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
请尝试以下步骤。
- 检查参考中的System.Web.Webpages版本。 说你的版本是= XXXX
2.在Webconfig中
a。首先添加组件
b。将程序集绑定到运行时
3.确保您添加了正确的密钥
这对我有用。 希望它也能帮到你。
我解决了这个问题,在项目的web.config
中添加以下行…
在我在MANAGE NUGET“Microsoft.AspNet.Mvc / 5.1.2”,“Microsoft ASP.NET Web Pages / 3.1.2”中标记之前,我尝试了一切,但没有任何作用(真的!!卸载VS并阅读了很多文章)
祝你好运
在我的情况下,这是由于我的笔记本电脑崩溃重启导致的程序集损坏。
要解决此问题,请按照以下步骤操作
-
清除项目的以下文件夹中的所有文件,或者只需单击清洁项目和清洁解决方案即可
- \ BIN
- \ OBJ
-
清理我的Win 7机器的Appdata临时文件夹,它位于Windows 7中的C:\ Users \ your_username \ AppData \ Local \ Temp \ Temporary ASP.NET Files
希望这可以帮助!
我通常做的是转到编译代码的机器,然后转到dos提示符并输入
C:> dir System.Web.WebPages.Depl* /s
通常可能有几个
c:/windows/Microsoft.Net/assembly/GAG_MSIL/System.web.WebPage/v....../
检查日期并确保与System.Web.WebPages.dll
相同,将其复制到目标计算机所在的bin。 这应该可以解决问题。
将此代码复制到Web.config的“配置”中,即可完成此操作