Debugging an XBAP / WCF application – Windows Vista + VS.NET 2008
June 11, 2008
Posted by on
Recently I was working on project involving XBAP & WCF. As usual WCF was providing the data to my XBAP presentation layer. The problem I immediately ran into was debugging XBAP. After searching over the web the closet I could was this link. A bunch of developers in my team who were using Windows XP got it working but somehow my machine running on Vista didn’t give in. Hence I decided to take the task myself up. After few trails & errors I got things moving as per below. Hope it saves your hair.
Step 1) Ensure that partial trust (Right Click Project in Solution Explorer -> Properties) is selected. Note debugging in full trust is easy (just F5 would work placing a break point in Service implementation) but that might give you a false sense of comfort considering the publish of XBAP applications work only in partial trust.
Step 2) Ensure that you have already published your project once. Right Click Project -> Publish -> Give a localhost site name e.g. http://localhost/RootPOC & click on finish.
Step 3) Important one. Click on debug tab. Select the start external program radio button & give the PresentationHost.exe path. Beneath in start options enter the command line options as
-debug (your publish location + projectname.xbap) – debugSecurityZoneUrl (your WCF Service Url)
E.g. -debug “http://localhost/RootPOC/WpfBrowserApplication5.xbap” -debugSecurityZoneUrl http://localhost/WcfServiceWF
Step 4) Ensure the WCF Service debug option is set to true in web.config (assuming you have hosted WCF Service in IIS) <compilation debug=”true“>
Step 5) Run the application (F5). Click on Debug Menu -> Attach Process to select PresentationHost.exe. Then say ok.
Attach Process Dialog
Step 6) Now you can place a break point anywhere in your WCF Service. When you perform an action you would see that execution breaks at your breakpoint.
That’s it. You all set to debug WCF from an XBAP application on Windows Vista / VS 2008. Happy coding!!!