Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
If you have a WPF, WinForms, or Win32 desktop project in which you want to use features of the Windows App SDK, then you can install the Windows App SDK NuGet package in your project.
Prerequisites
Before you install and use the Windows App SDK NuGet package in your app, be sure these requirements are met:
Visual Studio is installed and configured for Windows app development.
Your WPF, WinForms, or Win32 project is configured to call WinRT APIs.
Instructions
Open an existing WPF, WinForms, or Win32 project in Visual Studio. Ensure that it's configured to Call Windows Runtime APIs.
In Visual Studio, open the NuGet Package Manager:
- Click Tools > NuGet Package Manager > Manage NuGet Packages for Solution....
– OR – - Right-click your project in Solution Explorer, and choose Manage NuGet Packages for Solution....
- Click Tools > NuGet Package Manager > Manage NuGet Packages for Solution....
In the NuGet Package Manager window select the Browse tab and search for the following package:
- Microsoft.WindowsAppSDK.
After you've found the appropriate Windows App SDK NuGet package, select the package, check the box in the right-hand pane of the NuGet Package Manager window next to the project where you want to install the package, then click Install.
Note
The Windows App SDK NuGet package contains other sub-packages (including Microsoft.WindowsAppSDK.Foundation, Microsoft.WindowsAppSDK.WinUI, and others) that contain the implementations for specific components in the Windows App SDK. In general, we recommend that you install the main Windows App SDK NuGet package, which includes all of the components. In some cases, you can install a sub-package individually in order to reference only certain components in your project. For example, see Install and deploy Windows ML.
Additional steps for framework-dependent unpackaged apps
If your app is unpackaged and framework-dependent, follow the additional steps below to install the runtime and establish a dynamic Framework dependency.
Packaged apps, including apps packaged with external location (sparse packages), can declare the Framework dependency statically with <PackageDependency> in AppxManifest.xml; they don't need Bootstrapper initialization for that dependency. Self-contained apps carry the Framework binaries app-locally and don't need a Framework MSIX dependency or Bootstrapper initialization for those binaries. See Windows App SDK deployment overview.
For more info about the terms packaged and unpackaged, see Packaging overview.
1. Install the Windows App SDK Runtime
The Windows App SDK Runtime needs to be installed on any machine where the app will run.
For your development machine, we recommend that you visit Latest Windows App SDK downloads, then download, unzip, and run either:
- The latest stable release under Runtime downloads.
- A version and release channel of the runtime that matches the version and release channel of the Microsoft.WindowsAppSDK NuGet package that you installed.
Choose the appropriate Installer option for your machine’s architecture.
Important
When your app is deployed, you will be responsible for deploying required Windows App SDK runtime packages to your end users. For more information, see Windows App SDK deployment guide for framework-dependent unpackaged apps.
2. Initialize the Windows App SDK Runtime
An unpackaged framework-dependent app must add the Framework package to its process package graph before using APIs from that package.
You can do that automatically when your app starts via auto-initialization.
In Solution Explorer, right-click your project, and choose Edit Project File.
Inside the
PropertyGroupelement, add aWindowsPackageTypeelement set toNone.
<WindowsPackageType>None</WindowsPackageType>
When you build your project, these files are added to your project in Visual Studio:
- MddBootstrapAutoInitializer.cs
- WindowsAppSDK-VersionInfo.cs
Manually edit your
.vcxprojfile.Inside the
<PropertyGroup Label="Globals">element, add aWindowsPackageTypeelement set toNone.
<WindowsPackageType>None</WindowsPackageType>
Note
If you have advanced needs (such as custom error handling, or to load a specific version of the Windows App SDK), then instead of auto-initialization you can call the bootstrapper API explicitly—for more info, see Initialize the Windows App SDK Framework package dynamically and Tutorial: Use the bootstrapper API in an unpackaged app.
Further info
If you encounter a Class not registered error when using a Windows App SDK component, check that your deployment configuration supplies that component. A framework-dependent app must have a Framework dependency in its process package graph, either statically through its package manifest or dynamically through Bootstrapper initialization. A self-contained app must deploy the required app-local binaries. For more info, see Initialize the Windows App SDK.
Next steps
Related content
Windows developer