Solo 1.0.0-alpha.2

This is a prerelease version of Solo.
dotnet add package Solo --version 1.0.0-alpha.2
NuGet\Install-Package Solo -Version 1.0.0-alpha.2
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="Solo" Version="1.0.0-alpha.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Solo --version 1.0.0-alpha.2
#r "nuget: Solo, 1.0.0-alpha.2"
#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.
// Install Solo as a Cake Addin
#addin nuget:?package=Solo&version=1.0.0-alpha.2&prerelease

// Install Solo as a Cake Tool
#tool nuget:?package=Solo&version=1.0.0-alpha.2&prerelease

Solo

[!WARNING] This library is a work in progress, and might not work as intended. In particular, it hasn't been tested at all on Linux yet.

A simple library to run a .NET app as single-instance and notify the existing instance, if any.

When the first instance of the app starts, it attempts to create a named pipe.

  • If the named pipe already exists, it means another instance of the app already exists. Solo then connects to the existing named pipe, and sends the arguments to the existing instance, so that it can react appropriately.
  • If it doesn't, the app can start normally. Solo waits for connections from other instances to receive their arguments.

Additionally, on Windows only, the new instance allows the existing instance to set the foreground window. This is necessary because of the rules to prevent windows from stealing focus: without this, the existing instance could react when a new instance is started, but it would stay in the background, which would lead to a poor user experience.

Getting started

Install the package, and add this at the beginning of your Main method (or directly in Program.cs, if using top-level statements):

using var singleInstanceApp = new SingleInstanceApp(
    "MyTestApp",
    args => Console.WriteLine("New instance started!"));
if (!singleInstanceApp.TryStart(args))
{
    return;
}

// The rest of your code goes here

The delegate passed to the SingleInstanceApp constructor is invoked when another instance of the app is started.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

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.0-alpha.2 56 2/20/2024
1.0.0-alpha.1 70 1/2/2024