Debugging an XBAP / WCF application – Windows Vista + VS.NET 2008
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.

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.

Publish
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.

Break Point
That’s it. You all set to debug WCF from an XBAP application on Windows Vista / VS 2008. Happy coding!!!
Posted on June 11, 2008, in Windows Presentation Foundation and tagged Windows Presentation Foundation. Bookmark the permalink. 15 Comments.


Hy,
I tried your approach, but if I set a breakpoint in my xbap application, vs tells me, that there is no debugging information available. The same message comes, when I try to attach to the xbap later, when its running. I compiled with debug information enabled. If I start it the “normal” way with F5 and the direct link to the debug output, it works, but wcf does not work anymore. How did you do it exactly?
Regards
Daniel
I found the error in your post: You cannot use a URI for the location of the compiled xbap. You will always get the error, that URIs are not supported, which is correct for the location of the xbap. If I use the harddisk path of the xbap it will work. The debugSecurityZoneUrl must be a URI as you said.
Have a look at my homepage, where i posted a full article about xbap, wcf and debugging under the following url: http://www.kreuzhofer.de/wordpress/2008/06/24/xbap-wcf-and-debugging-with-visual-studio-2008/
Hi Daniel,
Sorry for late reply. I was tied up with some personal work. Are you working on Vista? I had initally tried without URI but it didn’t quite work on Vista. But after using URI things worked fine for me.
Hello, i tried doing all that but my application is not working despite having Wcf service and Xbap application is the same domain, having same publich url. I am stuck
Hi Aditya,
Can you isolate the code & send it to me in a zip file – niraj_rules@rediffmail.com?
hi niraj,
hope and wish you are doing fine.
i tried to create a wpf browser application which will insert an user into the table.
but i am stuck for a long time in this. am not even able to insert a single user.
when i try to insert there is an expection
“System.Security.SecurityException was unhandled by user code
Message=”Request for the permission of type ‘System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.”
Source=”mscorlib”
i am new to wpf, trying to create a wpf browser application.
and i have a doubt.is it a must, to have a webservice in a wpf browser application?
i mean is it possible for a wpf to work without webservices.
please advice.
if possible could you please help me with any working samples involving wpf browser applications on crud operations.
thanks in advance,
kind regards,
ithyan.
Hi Ithyan,
That’s because XBAP (WPF Browser) applications by default run in partial trust. You won’t be able to open a connection from it straight away. You can either invoke a WCF Service on top of basicHttpBinding to retrieve data or execute XBAP in full trust by changing security settings in the project file. If you have issues with outlined approaches let me know. Happy coding
hi niraj,
thanks for your prompt response.
after changing the application into a full trust one,i was able to insert.
considering this case and your explanation, shall i continue building my application without WCF or i should use wcf.
the nature of my application is something which involves crud operations with some calculations.
please advice.
kind regards,
ithyan.
Hi Ithyan,
What’s your motivation of using XBAP (WPF Browser) application? Normally people use it to run applications with limited permissions, like a sandbox execution. If that is your goal as well, WCF would be a better approach (full trust would make it like a WPF application inside browser). Hope you had a look at silverlight as well.
hi niraj,
my requirement is to host an intranet application.
will a full trusted application affect the operations in any way.
sorry am yet to have a look at silverlight.
but will start today.
thanks®ards,
ithyan.
Hi Ithyan,
Full trust will give a full access to the underlying resources of the client’s machine where application is running. For Intranet I guess it should be ok, though you need to check your non functional requirements. All the best!!!
Thank u!!!!
Salvaste mi dia:)
Pingback: xbap, wcf and debugging with visual studio 2008 at Daniel Kreuzhofers Weblog
Pingback: Wishing you the best 2009 has to offer « Niraj Bhatt - Architect’s Blog