How to start aspnet_wp.exe without firing Application_Start event

穿精又带淫゛_ 提交于 2019-12-12 23:04:24

问题


I'm trying to debug a web service (Windows XP SP3, VS 2008, ASP.NET 2, VB.NET).

For most of it, if the asp.net worker process is already loaded, I can start the Windows form that calls the web service, attach to aspnet_wp.exe in Visual Studio, and then debug to my heart's content, but catching the Application Start event in global.asax is a pain.

If I reset IIS, of course there is no process to attach to, until the Application start event is all over.

The only way I've found to do this is create a separate aspx page, set it as the start page, and run that - then I can stop on the break in the App start event, but it's a nuisance having to maintain a page that's essentially just a test stub.

Any ideas for something a bit neater? Kind of, "Attach to a process as soon as it starts".

Better still, of course, would be not to have to attach explicitly to aspnet_wp.exe in order to be able to debug the web service, but I haven't found a way of doing that either.

Thanks for any suggestions.


回答1:


Try sticking this in your Application Start event, it should kick your debugger everytime. Just make sure you take it out when you're done :-).

System.Diagnostics.Debugger.Launch()

Or better yet, in the OnStart of your WebService:

Protected Overrides Sub OnStart(ByVal args() As String)
    ' Add code here to start your service. This method should set things
    ' in motion so your service can do its work.
    System.Diagnostics.Debugger.Launch()
End Sub

Update: Adding this comment to the answer since it's a good idea:

Wrap this in #if DEBUG and it's a bit safer (won't end up slipping something so catastrophic into test/production environments). – sliderhouserules



来源:https://stackoverflow.com/questions/436941/how-to-start-aspnet-wp-exe-without-firing-application-start-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!