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" />
                    
Directory.Packages.props
<PackageReference Include="WinUI.SingleInstanced" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=WinUI.SingleInstanced&version=1.0.1
                    
Install as a Cake Tool

WinUI.SingleInstanced

Build NuGet

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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 79 5/30/2026
1.0.0 97 5/30/2026 1.0.0 is deprecated because it is no longer maintained and has critical bugs.