CoreSuite.CMessageBox
1.1.1
See the version list below for details.
dotnet add package CoreSuite.CMessageBox --version 1.1.1
NuGet\Install-Package CoreSuite.CMessageBox -Version 1.1.1
<PackageReference Include="CoreSuite.CMessageBox" Version="1.1.1" />
<PackageVersion Include="CoreSuite.CMessageBox" Version="1.1.1" />
<PackageReference Include="CoreSuite.CMessageBox" />
paket add CoreSuite.CMessageBox --version 1.1.1
#r "nuget: CoreSuite.CMessageBox, 1.1.1"
#:package CoreSuite.CMessageBox@1.1.1
#addin nuget:?package=CoreSuite.CMessageBox&version=1.1.1
#tool nuget:?package=CoreSuite.CMessageBox&version=1.1.1
CMessageBox
A customizable Windows Forms message box with typed dialogs, exception details and optional email reporting.
CMessageBox is part of the CoreSuite solution. It provides a consistent alternative to the standard WinForms MessageBox for information, success, warning, question and error messages.
Overview
CMessageBox exposes shared Show overloads that can be called throughout a Windows Forms application. Its global Options property controls fonts, colors, icons, exception-detail visibility, contextual diagnostic data and SMTP reporting. Exception capture, serialization and delivery are delegated to CoreSuite.ExceptionReporter, keeping reporting logic independent from the interface.
Question dialogs return DialogResult.Yes or DialogResult.No. Information, success, warning and error dialogs return DialogResult.OK when confirmed.
Features
- Information, success, warning, question and error message types.
- Multiple
Showoverloads for simple and detailed usage. - Custom title and message fonts and colors.
- Custom 64 × 64 message icons.
- Optional expandable exception details serialized as JSON.
- Additional contextual information in exception reports.
- Optional asynchronous exception reporting through SMTP.
- Configurable SMTP security mode.
- Designed for .NET 8 Windows Forms applications.
Requirements
- Windows Forms
- .NET 8 for Windows (
net8.0-windows)
Installation
Install the package from NuGet:
dotnet add package CoreSuite.CMessageBox
Or search for CoreSuite.CMessageBox in the Visual Studio NuGet Package Manager.
Namespace
Imports CoreSuite.Controls
Quick start
Imports CoreSuite.Controls
CMessageBox.Show("The operation was completed successfully.", "Completed", CMessageBoxType.Success)
Information message
CMessageBox.Show("Your changes were saved.")
Question message
Dim Result As DialogResult = CMessageBox.Show("Do you want to continue?", "Confirmation", CMessageBoxType.Question)
If Result = DialogResult.Yes Then
ContinueOperation()
End If
Error with exception details
Try
RunOperation()
Catch Ex As Exception
CMessageBox.Show("The operation could not be completed.", "Application error", Ex)
End Try
Global configuration
Configure CMessageBox.Options once during application startup:
CMessageBox.Options = New CMessageBoxOptions With {
.ShowExceptionDetails = True,
.TitleFont = New Font("Segoe UI", 11.25F, FontStyle.Bold),
.TitleForeColor = Color.FromArgb(32, 32, 32),
.MessageFont = New Font("Segoe UI", 9.75F),
.MessageForeColor = Color.FromArgb(64, 64, 64),
.AdditionalInformations = New Dictionary(Of String, Object) From {
{"ApplicationVersion", Application.ProductVersion},
{"MachineName", Environment.MachineName}
}
}
The configured instance is shared by every subsequent call to CMessageBox.Show.
Custom icons
Use the image properties in CMessageBoxOptions to configure the icon for each message type:
CMessageBox.Options.InformationImage = My.Resources.InformationIcon
CMessageBox.Options.SuccessImage = My.Resources.SuccessIcon
CMessageBox.Options.WarningImage = My.Resources.WarningIcon
CMessageBox.Options.QuestionImage = My.Resources.QuestionIcon
CMessageBox.Options.ErrorImage = My.Resources.ErrorIcon
Use 64 × 64 pixel images for the layout expected by the component.
Exception reporting by email
Set ExceptionEmail to send serialized exception details through an SMTP server when an error is displayed:
CMessageBox.Options.ExceptionEmail = New CMessageBoxExceptionEmail With {
.FromName = "Application",
.FromEmail = "sender@example.com",
.ToName = "Support",
.ToEmail = "support@example.com",
.Host = "smtp.example.com",
.Port = 587,
.Password = Environment.GetEnvironmentVariable("APP_SMTP_PASSWORD"),
.SecureSocket = CMessageBoxSecureSocket.StartTls
}
Do not store SMTP passwords directly in source code. Use environment variables, user secrets or another secure configuration provider.
Email sending runs asynchronously and communication failures do not interrupt the message-box flow.
API reference
CMessageBox
Public Class CMessageBox
Options
Public Shared Property Options As CMessageBoxOptions
Show overloads
Public Shared Function Show(Message As String) As DialogResult
Public Shared Function Show(Message As String, Title As String) As DialogResult
Public Shared Function Show(Message As String, MessageType As CMessageBoxType) As DialogResult
Public Shared Function Show(Message As String, Exception As Exception) As DialogResult
Public Shared Function Show(Message As String, Title As String, Exception As Exception) As DialogResult
Public Shared Function Show(Message As String, Title As String, MessageType As CMessageBoxType, Optional Exception As Exception = Nothing) As DialogResult
An exception can only be supplied when MessageType is CMessageBoxType.Error; otherwise, an ArgumentException is thrown.
CMessageBoxType
| Value | Buttons | Result |
|---|---|---|
Information |
OK | DialogResult.OK |
Success |
OK | DialogResult.OK |
Error |
OK; optional Details | DialogResult.OK |
Warning |
OK | DialogResult.OK |
Question |
Yes and No | DialogResult.Yes or DialogResult.No |
CMessageBoxOptions
| Property | Type | Purpose |
|---|---|---|
ShowExceptionDetails |
Boolean |
Shows the expandable details area for errors with exceptions. |
ExceptionEmail |
CMessageBoxExceptionEmail |
Defines optional SMTP reporting. |
TitleFont |
Font |
Controls the title font. |
TitleForeColor |
Color |
Controls the title color. |
MessageFont |
Font |
Controls the message font. |
MessageForeColor |
Color |
Controls the message color. |
AdditionalInformations |
Dictionary(Of String, Object) |
Adds contextual values to exception reports. |
ErrorImage |
Image |
Icon used for error messages. |
SuccessImage |
Image |
Icon used for success messages. |
InformationImage |
Image |
Icon used for information messages. |
WarningImage |
Image |
Icon used for warning messages. |
QuestionImage |
Image |
Icon used for question messages. |
CMessageBoxSecureSocket
| Value | Behavior |
|---|---|
Auto |
Allows MailKit to select the connection security mode. |
StartTls |
Requires an upgrade to TLS with STARTTLS. |
StartTlsWhenAvailable |
Uses STARTTLS when the server supports it. |
SslOnConnect |
Establishes TLS immediately when connecting. |
None |
Uses an unencrypted SMTP connection. |
Package dependencies
The package uses:
CoreSuite.ExceptionReporterCoreSuite.ControlContainerCoreSuite.NoFocusCueButton
NuGet resolves declared package dependencies automatically when all CoreSuite dependencies are available in the configured package source.
Package information
| Item | Value |
|---|---|
| Package | CoreSuite.CMessageBox |
| Namespace | CoreSuite.Controls |
| Assembly | CoreSuite.CMessageBox |
| Target framework | net8.0-windows |
| UI framework | Windows Forms |
| Reporting dependency | CoreSuite.ExceptionReporter |
License
This package is distributed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows7.0
- CoreSuite.ControlContainer (>= 1.0.2)
- CoreSuite.ExceptionReporter (>= 1.0.1)
- CoreSuite.NoFocusCueButton (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Updated the CoreSuite.ControlContainer dependency to version 1.0.2 to include the latest important fixes.