无法在Razor 1.0.0.0上加载文件或程序集

本文关键字:加载 文件 程序集 Razor | 更新日期: 2023-09-27 18:18:02

在我的MVC3解决方案中,我做了一些更改,当我在重建后进行调试时,我得到错误:

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

做一个递归GET修复这个问题,直到我重新构建,看到我的变化,然后解决方案中断与相同的错误。我没有改变任何网页。配置文件,只有c#代码被检出。

如果程序集不正确,那么递归GET仍然会破坏解决方案,是吗?我不知道哪里出错了

堆栈跟踪:

[FileNotFoundException: Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.]
   System.Web.Mvc.PreApplicationStartCode.Start() +0
[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified..]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +556
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +516
[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'System.Web.WebPages.Razor, 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) +9885060
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

无法在Razor 1.0.0.0上加载文件或程序集

我刚刚在构建服务器上遇到了类似的情况。问题似乎是System.Web.Mvc.dll的副本被复制到'bin中,而该副本在上次成功构建时并不存在,并且它可能正在制作和/或错误路由对System.Web.WebPages.Razor的需求。

从输出'bin中删除不必要的System.Web.Mvc.dll使我回到工作如期。

添加更多的.dll到输出的'bin(包括System.Web.WebPages.Razor和Microsoft.Web.Infrastructure)也让我回到工作如预期。

我猜"新的。dll在构建过程中被添加,尽管没有代码/项目更改"是作为本周早些时候一堆构建服务器补丁的副作用。