I just recently learned that you can distribute WPF-application web-wise using something called XBAP. You create a project in Visual Studio named WPF Browser Application and you´re on the road.

However, there are a couple of things to take in consideration. By default the XBAP will run in Partial Trust, something I hit into quite fast since I needed to make use of a COM-library to view PDF-files. Thus I needed a Windows Forms Host which I could add with no problems but when executing I recieved this neat error:

Attempt by security transparent method ‘DynamicClass.WindowsFormsHostCtor(System.Object[])’ to access security critical method ‘System.Windows.Forms.Integration.WindowsFormsHost..ctor()’ failed.

Apperantly you need to do two things to get this to work.

First up, sign your application, by default this should be setup in the project already, you will notice the YourProjectName_TemporaryKey.pfx in your solution explorer, you should change this to proper signing but for now it´s enough. We need to add this cert. as a Trusted Root Certificate and Trusted Publisher, just double click the file and follow the guide (twice) and you should be able to figure out what to do.

Second thing we need to do is to change the trust for the app in the project properties. Set this to full trust:

Now you should be on your road, happy distributing!

Why not join the newsletter?

Why not join the newsletter?

If you're not a fan of facebook or twitter, sign up to the newsletter and I'll send you a quick update every so often with what's going on and new posts coming out.

You have Successfully Subscribed!