XAML browser applications (XBAPs) combines features of both Web applications and rich-client applications. Like Web applications, XBAPs can be deployed to a Web server and started from Internet Explorer or Firefox. Like rich-client applications, XBAPs can take advantage of the capabilities of WPF. Developing XBAPs is also similar to rich-client development. This topic provides a simple, high-level introduction to XBAP development and describes where XBAP development differs from standard rich-client development.
This topic contains the following sections:
Creating a New XAML Browser Application (XBAP)
Deploying an XBAP
Communicating with the Host Web Page
XBAP Security Considerations
XBAP Start Time Performance Considerations
Creating a New XAML Browser Application (XBAP)
The simplest way to create a new XBAP project is with Microsoft Visual Studio 2010. When creating a new project, select WPF Browser Application from the list of templates. For more information, see How to: Create a New WPF Browser Application Project.
When you run the XBAP project, it opens in a browser window instead of a stand-alone window. When you debug the XBAP from Microsoft Visual Studio, the application runs with Internet zone permission and will therefore throw security exceptions if those permissions are exceeded. For more information, see Security (WPF) and WPF Partial Trust Security.
Note
If you are not developing with Microsoft Visual Studio or want to learn more about the project files, see Building a WPF Application (WPF).
Deploying an XBAP
When you build an XBAP, the output includes the following three files:
File
Executable (.exe)
Description
This contains the compiled code and has an .exe extension.
File
Application manifest (.manifest)
Description
This contains metadata associated with the application and has a .manifest extension.
File
Deployment manifest (.xbap)
Description
This file contains the information that ClickOnce uses to deploy the application and has the .xbap extension.
You deploy XBAPs to a Web server, for example Microsoft Internet Information Services (IIS) 5.0 or later versions. You do not have to install the .NET Framework on the Web server, but you do have to register the WPF Multipurpose Internet Mail Extensions (MIME) types and file name extensions. For more information, see How to: Configure IIS 5.0 and IIS 6.0 to Deploy WPF Applications.
To prepare your XBAP for deployment, copy the .exe and the associated manifests to the Web server. Create an HTML page that contains a hyperlink to open the deployment manifest, which is the file that has the .xbap extension. When the user clicks the link to the .xbap file, ClickOnce automatically handles the mechanics of downloading and starting the application. The following example code shows an HTML page that contains a hyperlink that points to an XBAP.
<html>
<head></head>
<body>
Click this link to launch the application
</body>
</html>
You can also host an XBAP in the frame of a Web page. Create a Web page with one or more frames. Set the source property of a frame to the deployment manifest file. If you want to use the built-in mechanism to communicate between the hosting Web page and the XBAP, you must host the application in a frame. The following example code shows an HTML page with two frames, the source for the second frame is set to an XBAP.
<html>
<head>A page with frames.</head>
<frameset cols="50%,50%">
<frame src="introduction.htm" >
<frame src="XbapEx.xbap" >
</frameset>
</html>
Clearing Cached XBAPs
In some situations after rebuilding and starting your XBAP, you may find that an earlier version of the XBAP is opened. For example, this behavior may occur when your XBAP assembly version number is static and you start the XBAP from the command line. In this case, because the version number between the cached version (the version that was previously started) and the new version remains the same, the new version of the XBAP is not downloaded. Instead, the cached version is loaded.
Read more: MSDN
This topic contains the following sections:
Creating a New XAML Browser Application (XBAP)
Deploying an XBAP
Communicating with the Host Web Page
XBAP Security Considerations
XBAP Start Time Performance Considerations
Creating a New XAML Browser Application (XBAP)
The simplest way to create a new XBAP project is with Microsoft Visual Studio 2010. When creating a new project, select WPF Browser Application from the list of templates. For more information, see How to: Create a New WPF Browser Application Project.
When you run the XBAP project, it opens in a browser window instead of a stand-alone window. When you debug the XBAP from Microsoft Visual Studio, the application runs with Internet zone permission and will therefore throw security exceptions if those permissions are exceeded. For more information, see Security (WPF) and WPF Partial Trust Security.
Note
If you are not developing with Microsoft Visual Studio or want to learn more about the project files, see Building a WPF Application (WPF).
Deploying an XBAP
When you build an XBAP, the output includes the following three files:
File
Executable (.exe)
Description
This contains the compiled code and has an .exe extension.
File
Application manifest (.manifest)
Description
This contains metadata associated with the application and has a .manifest extension.
File
Deployment manifest (.xbap)
Description
This file contains the information that ClickOnce uses to deploy the application and has the .xbap extension.
You deploy XBAPs to a Web server, for example Microsoft Internet Information Services (IIS) 5.0 or later versions. You do not have to install the .NET Framework on the Web server, but you do have to register the WPF Multipurpose Internet Mail Extensions (MIME) types and file name extensions. For more information, see How to: Configure IIS 5.0 and IIS 6.0 to Deploy WPF Applications.
To prepare your XBAP for deployment, copy the .exe and the associated manifests to the Web server. Create an HTML page that contains a hyperlink to open the deployment manifest, which is the file that has the .xbap extension. When the user clicks the link to the .xbap file, ClickOnce automatically handles the mechanics of downloading and starting the application. The following example code shows an HTML page that contains a hyperlink that points to an XBAP.
<html>
<head></head>
<body>
Click this link to launch the application
</body>
</html>
You can also host an XBAP in the frame of a Web page. Create a Web page with one or more frames. Set the source property of a frame to the deployment manifest file. If you want to use the built-in mechanism to communicate between the hosting Web page and the XBAP, you must host the application in a frame. The following example code shows an HTML page with two frames, the source for the second frame is set to an XBAP.
<html>
<head>A page with frames.</head>
<frameset cols="50%,50%">
<frame src="introduction.htm" >
<frame src="XbapEx.xbap" >
</frameset>
</html>
Clearing Cached XBAPs
In some situations after rebuilding and starting your XBAP, you may find that an earlier version of the XBAP is opened. For example, this behavior may occur when your XBAP assembly version number is static and you start the XBAP from the command line. In this case, because the version number between the cached version (the version that was previously started) and the new version remains the same, the new version of the XBAP is not downloaded. Instead, the cached version is loaded.
Read more: MSDN