Saturday, February 23, 2013

Using PowerBuilder.Net Visual Components in WPF Browser Applications

In an earlier blog post I demonstrated how you can create visual components in PowerBuilder.Net and then use them from within Visual Studio (including the Express version that you can download free of charge from Microsoft).  What I created in Visual Studio for that demonstration was a WPF application, but there are other things you can do with PowerBuilder.Net visual components when you get them into Visual Studio.  One of those is to create a WPF Browser Application.

WPF Browser Application (also called 'XBAP', short for XAML Browser Application) is a method of running WPF applications within a browser and still maintain rich client functionality.  Think of it as the half way point betweenClickOnce (in which the application is simply distributed through the browser, but runs independently on the local machine) and SilverLight (where the application runs within the browser).  An XBAP application runs 'within' the browser to the extent that it uses it as the host that it displays in, so it appears to be a web application.  Like ClickOnce, it requires that the .Net Framework is was written referencing be deployed on the client, and will prompt the user to install it if it is not available.

In order to run XBAPs within Internet Explorer you must first customize one of the security settings to enable them.  The plugin that allows XBAPs to run within Firefox is distributed with .Net Framework 3.5.  Once it is installed, adding the location to it to the system path then enables Chrome and Opera to run XBAPs as well.  This site provides extensive details on getting the various browsers configured correctly.

XBAPs normally operate under partial trust.  However, depending on what your application needs to do you may need to elevate it's permissions to allow it to operate under full trust.  This site provides detains on enabling an XBAP to run under full trust.  For the sample app I used in that demo I needed to configure the XBAP to run under full trust because I wanted to do a binding redirect on the Oracle ODP.Net libraries and a binding redirect requires full trust.

Note that you will need to use PowerBuilder 12.5.1 (the maintenance release, not the original 12.5 release) in order to create the visual component.  One of the significant enhancements in that maintenance release was support forcompiling applications and components to support x64 and AnyCPU targets.  Assemblies created for use in XBAP applications have to target AnyCPU.

Having said all that, here's what the sample component looks like when compiled as an XBAP and then accessed via Internet Explorer:


Here's the same XBAP being accessed from Firefox:

From Chrome:

And finally from Opera:


No comments: