【问题标题】:rebuilding solution causes Could not load file or assembly on Razor 1.0.0.0重建解决方案原因无法在 Razor 1.0.0.0 上加载文件或程序集
【发布时间】:2014-08-14 10:17:21
【问题描述】:

在我的 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 可以解决此问题,直到我再次重建以查看我的更改,然后解决方案因相同的错误而中断。我没有更改任何 web.config 文件,它只是签出的 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

【问题讨论】:

    标签: c# asp.net-mvc asp.net-mvc-3 razor


    【解决方案1】:

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

    从输出 \bin 中删除不必要的 System.Web.Mvc.dll 让我回到按预期工作。

    向输出 \bin(包括 System.Web.WebPages.Razor 和 Microsoft.Web.Infrastructure)添加更多 .dll 也让我回到了按预期工作的状态。

    我猜想“尽管没有代码/项目更改,但在构建期间添加了新的 .dll”是本周早些时候一系列构建服务器补丁的副作用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-01
      • 2015-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多