Partager via


Deploying a Windows Presentation Foundation Application

Once a Windows Presentation Foundation (WPF) application is built, it needs to be deployed to the user. How a WPF application is deployed depends on the type of application it is, and what deployment mechanism it uses.

WPF offers two main application types:

  • Standalone.

  • Browser-Hosted (XAML browser applications (XBAPs) or markup-only Extensible Application Markup Language (XAML) pages.

Depending on their requirements, WPF applications can be deployed using existing deployment and installation technologies, including:

While these technologies are well documented, this topic provides a brief overview of them, as well as the typical deployment scenarios for each type of WPF application and any pertinent considerations.

This topic contains the following sections.

  • Deployment Technologies
  • Deploying WPF Applications
  • Installing .NET Framework 3.0
  • Related Topics

Deployment Technologies

XCopy Deployment

XCopy deployment refers to the use of the XCopy command line program to copy files from one location to another. XCopy deployment is suitable in the following scenarios:

  • Installed applications that are completely self-contained.

  • Moving application files from one location to another, such as from a build location to a publish location like a Web site or Universal Naming Convention (UNC) file share.

  • Applications that do not require shell integration such as Start Menu short cuts, desktop icons, etc.

  • Applications that do not require access to machine resources such as the Registry to be installed.

In general, XCopy is a fairly limited deployment technology because it requires additional management to deploy files to client machines, and does not support versioning, uninstallation, or rollback

Windows Installer

Windows Installer is a technology that allows applications to be packaged as self-contained executables that can be easily distributed to client machines and run. Furthermore, Windows Installer is a core part of Windows and enables integration with the desktop, the Start menu, the Add/Remove Programs control panel, and a host of other installation features.

While Windows Installer does make it easy to install and remove applications, it does not provide facilities to ensure that installed applications are kept up to date from a versioning standpoint.

ClickOnce Deployment

ClickOnce is a specialized deployment technology that fundamentally enables Web-style application deployment for non-Web applications: applications are published to and browsed from Web servers. The biggest benefit of using ClickOnce is the ability to keep applications up to date as easily as Web applications simply by copying new application versions to Web servers.

While ClickOnce does not support the full range of client-side integration that applications installed with Windows Installer get, ClickOnce applications have the following capabilities:

  • Depending on the type of application, they can be installed onto the client machine, with Start menu and Add/Remove Programs control panel integration.

  • Support for versioning, rollback, and uninstallation.

  • Alternatively, ClickOnce-deployed applications can be run without touching the client machine. This is known as the online install mode.

NoteNote:

This topic does not cover ClickOnce in-depth. For more information on ClickOnce, see ClickOnce Deployment.

Deploying WPF Applications

The deployment options that can be used are determined by the type of WPF application that is being deployed, including markup-only XAML applications, XBAPs, and standalone applications.

Deploying Markup-Only XAML Applications

In general, users browse to markup-only XAML pages in the same way that they browse to HTML pages. Consequently, markup-only XAML pages are typically published to a Web server, and browsed to using Internet Explorer.

When browsed, WPF uses ClickOnce to facilitate the launch process, Additionally, markup-only XAML pages only have the permissions that are provided to applications launched from the Internet zone (see Windows Presentation Foundation Security).

While unlikely it is possible to install a markup-only XAML application to local disk using XCopy or Windows Installer. Such applications can still be launched from the local disk using Internet Explorer or Windows File Explorer.

Deploying XAML Browser Applications

An XBAP is a compiled application that requires at least the following three files to be deployed:

  • ApplicationName .exe: The executable assembly application file.

  • ApplicationName .xbap: The deployment manifest, which is what users browse or double-click to launch an XBAP.

  • ApplicationName .exe.manifest: The application manifest.

NoteNote:

See Building a Windows Presentation Foundation Application for more information on deployment and application manifests.

These files are produced when an XBAP is built using MSBuild, and are the core set of files you need to deploy. Like markup-only XAML pages, an XBAP is typically published to a Web server, and browsed with Internet Explorer.

While XBAPs are launched using ClickOnce, they cannot be configured to be installed on the client machine. If you need to install an XBAP on a client machine (eg to run with full trust), you can use XCopy or Windows Installer as appropriate.

An advantage of launching an XBAP from the local disk is that it can run with full trust (see Windows Presentation Foundation Security), giving it access to the full range of system resources, including the Windows Registry, the local disk, and the Windows Event Log.

A key disadvantage is that you lose the automatic update ability that XBAPs provides by being deployed from a server using ClickOnce. However, this is not an issue if your application is designed to be a standalone application that integrates with Windows Internet Explorer for the user experience.

Deploying Standalone Applications

A standalone application is typically deployed using either ClickOnce or Microsoft Windows Installer.

By default, standalone applications that are launched using ClickOnce receive full trust (see Windows Presentation Foundation Security). This is fine if your application requires access to the full range of system resources, including the Windows Registry, the local disk, and the Windows Event Log. However, ClickOnce will display a security warning dialog that users must accept before the application can be installed. If you want your users to launch an application without a security warning being displayed, or your application simply doesn't need full trust, you should consider using XBAPs.

Installing .NET Framework 3.0

To be able to run any kind of WPF application, the Microsoft .NET Framework version 3.0 must be installed on the client machine. When WPF browser-hosted applications are launched from Windows Internet Explorer 7, Windows Internet Explorer 7 automatically detects whether the client machine has .NET Framework 3.0 installed. If not, Internet Explorer 7 prompts the user to install it before continuing.

To facilitate this capability, Internet Explorer 7 includes a .NET Framework 3.0 bootstrapper application that is registered as the fallback Multipurpose Internet Mail Extensions (MIME) handler for content files with the following extensions: .xaml, .xps, .xbap, and .application. When any of these file types are navigated to, and the .NET Framework 3.0 is not installed on the client machine, Internet Explorer 7 notifies the user that .NET Framework 3.0 is required and asks their consent to install it. If a user doesn't provide their consent, neither the .NET Framework 3.0 nor the application is subsequently installed.

If a user does provide their consent, Internet Explorer 7 proceeds to download and install the .NET Framework 3.0 using the Microsoft Background Intelligent Transfer Service (BITS). After successful installation of the .NET Framework 3.0, the originally requested file is launched in a new browser window.

This feature is available on client machines that have Internet Explorer 7 installed on Windows Vista, Microsoft Windows XP Service Pack 2 (SP2), or Microsoft Windows Server 2003 (SP1).

See Also

Concepts

Building a Windows Presentation Foundation Application
Windows Presentation Foundation Security