2013-04-08 67 views
1

如何調試System.Web.Compilation.BuildManager中的事件?並且在IIS/ASP.net生命週期的哪個階段被調用?如何在System.Web.Compilation.BuildManager中調試

問題是我有一些代碼使用PreApplicationStartMethodAttribute但似乎沒有觸發。所以我試圖找出將調試器附加到它的最佳方式。

有關於更大的問題在這裏一些細節 Why does PreApplicationStartMethodAttribute() not work in SharePoint 2013?,但我有它分成 較小的問題,試圖取得一些進展。

我只能夠識別以下調用堆棧到目前爲止...

BuildManager.CallPreStartInitMethods - > BuildManager GetPreStartInitMethodsFromAssemblyCollection()

+0

檢查'更大的問題'的問題,我發佈了一個答案,可以清除這一點。 – 2013-04-17 11:07:33

回答

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 
+0

這正是我所尋找的歡呼聲。 – 2013-04-18 00:28:05