CeltreSoftware.NativeMessageBox
1.2.1
dotnet add package CeltreSoftware.NativeMessageBox --version 1.2.1
NuGet\Install-Package CeltreSoftware.NativeMessageBox -Version 1.2.1
<PackageReference Include="CeltreSoftware.NativeMessageBox" Version="1.2.1" />
<PackageVersion Include="CeltreSoftware.NativeMessageBox" Version="1.2.1" />
<PackageReference Include="CeltreSoftware.NativeMessageBox" />
paket add CeltreSoftware.NativeMessageBox --version 1.2.1
#r "nuget: CeltreSoftware.NativeMessageBox, 1.2.1"
#:package CeltreSoftware.NativeMessageBox@1.2.1
#addin nuget:?package=CeltreSoftware.NativeMessageBox&version=1.2.1
#tool nuget:?package=CeltreSoftware.NativeMessageBox&version=1.2.1
CeltreSoftware's Native Message Box
A small .NET library for showing native message boxes through the operating system's own dialog APIs or tools.
The goal is simple: call one API from your application and let the library choose the most native implementation available for the current platform.
Installation
dotnet add package CeltreSoftware.NativeMessageBox
Usage
using CeltreSoftware.NativeMessageBox;
MessageBox.ShowInfo("Finished", "The operation completed successfully.");
MessageBox.ShowWarning("Low Disk Space", "You are running out of storage.");
MessageBox.ShowError("Import Failed", "The file could not be processed.");
If you prefer a non-throwing API, use the TryShow... methods:
var shown = MessageBox.TryShowInfo("Finished", "The operation completed successfully.");
Supported Message Box Types
The current public API supports three message box variants:
ShowInfoandTryShowInfoShowWarningandTryShowWarningShowErrorandTryShowError
All currently supported dialogs are single-button acknowledgement dialogs. They are meant for notifying the user, not for collecting a choice.
That means the library currently does not expose:
- yes/no dialogs
- ok/cancel dialogs
- retry/cancel dialogs
- custom button text
- custom icons beyond the built-in info, warning, and error variants
How Each Platform Generates Message Boxes
Windows
On Windows, the library calls the native Win32 MessageBoxW function from user32.dll.
ShowInfouses the Win32 information icon.ShowWarninguses the Win32 warning icon.ShowErroruses the Win32 error icon.
This is the most direct implementation in the project because it uses the platform API itself rather than launching an external process.
macOS
On macOS, the library uses Cocoa (AppKit) by calling Objective-C runtime APIs through .NET interop.
ShowInfomaps to an informationalNSAlert.ShowWarningmaps to a warning-styleNSAlert.ShowErrormaps to a critical-styleNSAlert.
Linux and FreeBSD
On Linux and FreeBSD, the library uses freedesktop/XDG desktop environment hints (XDG_CURRENT_DESKTOP, XDG_SESSION_DESKTOP, and DESKTOP_SESSION) to decide whether to use Zenity or KDialog.
- KDE/Plasma/LXQt-like environments prefer
kdialog. - GNOME/GTK-like environments prefer
zenity. - If the preferred tool is missing but the other one is installed, the library falls back to the available tool.
- If both tools are installed but no desktop hint can be resolved, the library treats the environment as ambiguous and fails instead of enforcing a global priority.
- If neither tool is installed, the library fails.
In throwing APIs, these failure cases raise PlatformNotSupportedException. In TryShow... APIs, they return false.
Zenity
When Zenity is selected by the environment-aware resolver, the library launches it with these dialog modes:
ShowInfouseszenity --infoShowWarninguseszenity --warningShowErroruseszenity --error
KDialog
When KDialog is selected by the environment-aware resolver, the library launches it with these dialog modes:
ShowInfouseskdialog --msgboxShowWarninguseskdialog --sorryShowErroruseskdialog --error
Platform Notes
- Windows support is implemented through Win32.
- macOS support is implemented through Cocoa (AppKit) interop.
- Linux and FreeBSD support depend on either
zenityorkdialogbeing installed and available onPATH. - Linux and FreeBSD tool selection is based on XDG/freedesktop desktop environment hints rather than a fixed global priority.
Error Behavior
ShowInfo,ShowWarning, andShowErrorthrow if the current platform is unsupported or if the dialog cannot be shown.TryShowInfo,TryShowWarning, andTryShowErrorcatch failures and returnfalseinstead.
License
This project is licensed under the MIT license. See LICENSE.md.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.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 |
|---|