Calling a ASP.Net 2.0 Webservice from an XBAP

Today, I was trying out a couple of things with WPF. Here is the scenario:

I created a simple XML file called "People.xml". My objective was to use this file as a database for my first data aware XBAP.

I had a lot of problems making it to work. The reason?

  • It actually tries to find the file in system32 folder
  • I couldn't figure out a way to send that file as part of deployment process.
  • This is actually a bad idea. Having local copies of database? nah...

The best idea is to have a WebService that acts as your business/data access layer.
This actually gives you a centralized database. So, I didn't break my head further and moved ahead implementing
the WebService solution. This solution also required a lot of brainstorming and troubleshooting.
We always used to get "Trust Not Granted" when we used "This is a Full Trust application".

When we used partial trust, it would fail with "System.Security.SecurityException"

Request for the permission on type System.Net.webPermission failed.


Problem, problem... never mind... there has to be a solution.


When we used a custom security settings for the ClickOnce deployment we got "Trust Not Granted".


The resolution to this problem is to install the temporary security certificate that is created by default in the XAML browser application. Its named in the format: <ApplicationMane>_TemporaryKey.pfx

You need to install this certificate at the client machines where the application is supposed to run, under Trusted Root Certificate and Trusted Publishers zone.

Once done, you can also use a Full Trust ClickOnce deployment.

Enjoy XBAP.