Niraj Bhatt – Architect's Blog

Ruminations on .NET, Architecture & Design

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.


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

Debug Options

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!!!


15 responses to “Debugging an XBAP / WCF application – Windows Vista + VS.NET 2008

  1. Daniel June 24, 2008 at 10:12 pm


    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?



  2. Daniel June 24, 2008 at 10:28 pm

    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.

  3. Daniel June 25, 2008 at 12:49 am

    Have a look at my homepage, where i posted a full article about xbap, wcf and debugging under the following url:

  4. Pingback: xbap, wcf and debugging with visual studio 2008 at Daniel Kreuzhofers Weblog

  5. nirajrules July 7, 2008 at 9:38 pm

    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.

  6. Pingback: Wishing you the best 2009 has to offer « Niraj Bhatt - Architect’s Blog

  7. Aditya January 15, 2009 at 2:36 pm

    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

  8. Ithyan March 13, 2009 at 7:40 pm

    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=, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.”

    i am new to wpf, trying to create a wpf browser application.
    and i have a 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,

  9. nirajrules March 13, 2009 at 10:07 pm

    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 🙂

  10. Ithyan March 13, 2009 at 10:30 pm

    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,

  11. nirajrules March 14, 2009 at 9:49 am

    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.

  12. ithyan March 18, 2009 at 7:47 am

    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.


  13. nirajrules March 20, 2009 at 11:08 am

    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!!!

  14. Anai June 17, 2010 at 11:36 am

    Thank u!!!!
    Salvaste mi dia:)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: