0

您如何调试System.Web.Compilation.BuildManager中的事件?它在 IIS/ASP.net 生命周期的哪个阶段被调用?

问题是我有一些使用PreApplicationStartMethodAttribute但似乎没有触发的代码。所以我试图找出将调试器附加到它的最佳方法。

这里有一些关于更大问题的更多详细信息 为什么 PreApplicationStartMethodAttribute() 在 SharePoint 2013 中不起作用?但我已将其分解为一个较小的问题,以尝试取得一些进展。

到目前为止,我只能识别以下调用堆栈...

BuildManager.CallPreStartInitMethods -> BuildManager.​GetPreStartInitMethodsFromAssemblyCollection()

4

1 回答 1

1

我正在研究类似的(或者可能是相同的问题),并且可以为您提供完整的堆栈跟踪。顺便说一句,您可以自己生成它,只需创建一个简单的小型 MVC 应用程序并在您使用 PreApplicationStartMethodAttribute 调用的方法中引发异常。你会得到:

[ApplicationException: joe was here]
   MvcApplication2.JoeStart.Start() in c:\Users\Joe\Documents\Visual Studio 2012\Projects\MvcApplication2\MvcApplication2\JoeStart.cs:18

[InvalidOperationException: The pre-application start initialization method Start on type MvcApplication2.JoeStart threw an exception with the following error message: joe was here.]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +550
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +132
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +90
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +135
   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 MvcApplication2.JoeStart threw an exception with the following error message: joe was here.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873784
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
于 2013-04-16T18:54:37.680 回答