Friday, January 18, 2008

Key items for using XBAP to WCF

  1. Get your WCF service running perfectly before coding against it.
  2. An XBAP component that is running under partial security internet, must be running in the same domain and port number as the WCF service.
  3. Under security tab, in the Application configuration, there is a button marked "Advanced...". Make sure that "Grant the application access to the site of origin" is checked.

At this point, you can build and deploy your application to your server for testing. Or if you WCF is on the same box as your XBAP, make sure that the host domain match.
In this case localhost is not the same as using your box name.
Make sure that you are either using your box name for both, or localhost for both.

Last key item, this is still for debugging. The default for debugging is that IE comes up with a file path to your XBAP which causes the connection to the service to fail. Here you have a problem with a simple solution.

  1. Again to to your application configuration. Go to Debug.
  2. Change "Start Action" to "Start external program", with the value of "c:\Windows\System32\PresentationHost.exe"
  3. In "Start Options" => "Command line arguments" enter:
    -debug (Physical Path) -debugSecurityZoneUrl (Domain path)
IE: -debug "c:\Users\ThisUser\Documents\Visual Studio 2008\Project\ThisProject\test.xbap" -debugSecurityZoneUrl http://www.tempuri.org

You may run into other issues, but these are the key ones that were hard for me to find.

To give credit where credit is due:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2695012&SiteID=1&mode=1
Thx to: Matt Galbraith - MSFT & Chango V. - MSFT