posts - 3 , comments - 3 , trackbacks - 0

My Links

News

Our new streamlined development process is composed of three stages -
  1. 1. Get it done
  2. 2. Just get it done
  3. 3. Is it done yet?

Article Categories

Archives

Post Categories

Debugging Castle WcfFacility installers

Stepping through IWindsorInstaller implementations in web services created using the WcfFacility[1] is not as immediately accessible compared to debugging the start up of a console application. Just pressing F5 with the web service set as a start up project causes the start up code to have already been run before the debugger attaches to the IIS worker process. Fortunately there is a simple way of causing the start up code to be re-run whilst remaining attached to the IIS worker process, so that you can step through your Castle installers and access the debugger views.

Once you've attached to the worker process under the debugger you can just rebuild the web service project to force IIS to re-initialize the newly built assembly when it is next exercised.
Once you've attached to the worker process under the debugger[2] you can just rebuild the web service project to force IIS to re-initialize the newly built assembly when it is next exercised. The IDE won't normally let you do this[3] so you have to build the web service project outside the IDE that is running the debugger. Of the various ways of doing this i'd like to suggest running the .csproj file directly in MSBuild.exe on the command line (because it means that just pressing the up arrow and enter in the command window will easily let you re-build). So with the debugger attached to the IIS worker process of your web service, just re-build the web service project on the command line e.g. 

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe My.Web.Service.csproj

As soon as you call any of its operations IIS will re-initialize the service causing the breakpoints to be hit. I hope this saved you some frustration as it took me a while to figure this one out. Happy Debugging.

[1] If you are using the Castle WcfFacility your My.Web.Service.svc will probably look something like this -

<%@ ServiceHost Language="C#" 
                Debug="true" 
                Service="My.Web.Service" 
                Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>

[2]  I.e. either you've just hit F5 with the web service project as the start up project, or you've attached to the worker process by selecting it in the processes list (If the worker process isn't showing in the list it might be because it isn't yet running, the worker process hosting the application pool can be started just by calling one of the web service operations. Alternatively you might have to tick the box to include processes from all sessions.)

[3] I've definitely seen a bug in VS2010 SP1 where under rare circumstances it will let you, i have been able to do this once but now have no idea how to reproduce this issue now...

Print | posted on Tuesday, May 15, 2012 10:00 AM | Filed Under [ Castle ]

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: