WinUI.SingleInstanced
1.0.1
dotnet add package WinUI.SingleInstanced --version 1.0.1
NuGet\Install-Package WinUI.SingleInstanced -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WinUI.SingleInstanced" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WinUI.SingleInstanced" Version="1.0.1" />
<PackageReference Include="WinUI.SingleInstanced" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WinUI.SingleInstanced --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: WinUI.SingleInstanced, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WinUI.SingleInstanced@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WinUI.SingleInstanced&version=1.0.1
#tool nuget:?package=WinUI.SingleInstanced&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
WinUI.SingleInstanced
Zero-setup single instancing for WinUI 3 applications. Based on article: Making the app single-instanced by Jingwei Zhang.
Usage
Install the package in your WinUI 3 application project, the application immediately becomes single-instanced. If you need to handle activation, subscribe to Program.Activated event:
namespace MyApp;
public partial class App
{
public App()
{
Program.Activated += OnActivated;
InitializeComponent();
}
private void OnActivated(object? sender, AppActivationArguments args)
{
// Handle launch, protocol, file, or other activation arguments here.
}
}
How it works
Package installation adds .target file to disable generation of default Main() method. Source generator creates Program.cs with Main() method that handles the activation.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows10.0.26100 is compatible. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0-windows10.0.26100
- Microsoft.Windows.SDK.BuildTools (>= 10.0.26100.6584)
- Microsoft.WindowsAppSDK (>= 1.8.260101001)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.