Windows Presentation Foundation: From a XBAP to an EXE
.NET,
Technical stuff,
WPF
See comments
I spent most of the day studying the project properties of WPF applications,
both Standalone and Browser applications, and comparing them. The goal is to find out
what are the minimal changes you have to apply to a project in order to run
an application in the browser, or outside of it.
(For those who don't know, WPF applications can run using Internet Explorer
as a host (XAML Browser Applications, XBAP), or standalone as a regular
EXE. For XBAP, restricted permissions apply (sandbox), and of course the navigation
model is different (Pages instead of Windows)).
It was quite a tiring task, but I think I managed to understand more or less
what every property in the CSPROJ file does and to extract the minimal changes
needed in order to run the XBAP as standalone.
- Create a WinFx Web Browser Application
- Close the solution
- Open the CSPROJ file in a text editor
- Set "HostInBrowser" to false
- Set "Install" to true
- Delete the tags: "StartAction", "StartProgram", "StartArguments" tag
- Open the project file in VS2005
- Replace the Page tag with a Window tag in the XAML file
- Replace the Page base class with Window base class in the CS file
- Build the project and execute
I must be honest, I am not really sure what this proves. I am really not sure that
using exactly the same code base for the Windows and the Web scenario is a possible choice.
After all, the navigation model is very different, but more importantly, in the web case,
you have a distributed environment (client-server). So what does it mean for the Windows
application? If the "client" part has to communicate with the "server" part using
Web Services only because of the constraints set by the Web scenario, isn't it too
much of a hassle for a Windows app? Isn't it too slow?
Also, how would one handle the permission problems? Ideally, the application should
react the same if it runs standalone or in the browser. However, if the permissions are
not carefully evaluated, the XBAP won't even install, especially if it runs in the
Internet zone. So should you always choose the "lesser permissions" scenario, just to be
safe? Is it really worth going through all that?
Or should we just follow the "two ways" model (one Windows application and one
Web application, separate requirements, separate deployment, separate application
model, separate teams...)?