Geeks With Blogs


What I do:

Identity Mine

MVVM Light


What I am:

Microsoft Most Valuable Professional, Client Application Development

Microsoft Certified Technology Specialist, Windows Presentation Foundation

WPF disciples


View my profile on LinkedIn

Creative Commons License
Diary of a Code Trotter by Laurent Bugnion is licensed under a Creative Commons Attribution 3.0 Unported License

All source code on this blog is licensed under the MIT license.

Copyright (c) 2006 - 2011 GalaSoft Laurent Bugnion

Laurent Bugnion (GalaSoft) Diary of a Code Trotter
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.
  1. Create a WinFx Web Browser Application
  2. Close the solution
  3. Open the CSPROJ file in a text editor
  4. Set "HostInBrowser" to false
  5. Set "Install" to true
  6. Delete the tags: "StartAction", "StartProgram", "StartArguments" tag
  7. Open the project file in VS2005
  8. Replace the Page tag with a Window tag in the XAML file
  9. Replace the Page base class with Window base class in the CS file
  10. 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...)?
Posted on Wednesday, June 28, 2006 7:52 PM Technical stuff , .NET , WPF | Back to top

Comments on this post: Windows Presentation Foundation: From a XBAP to an EXE

# re: Windows Presentation Foundation: From a XBAP to an EXE
Requesting Gravatar...
I found it is not necessary to replace the <Page></Page> tags with <Window></Window> tags, or change the base class. This creates a navigator for your page, and you will see a little bar at the top of the window with a back and forward button...

Also if you find that it is necessary for you, it might make sense to have two copies of the same thing (one with page tags, one with window tags) and you can simply switch the StartupUri...

<!-- app.xaml -->

<Application ...




<!-- app.xaml -->

<Application ...



This is great though!!!

Left by Bogdan on Jun 19, 2007 8:55 AM

Comments have been closed on this topic.
Copyright © Laurent Bugnion | Powered by: