![]() |
VOOZH | about |
dotnet add package CP.Extensions.Hosting.Wpf --version 3.1.26
NuGet\Install-Package CP.Extensions.Hosting.Wpf -Version 3.1.26
<PackageReference Include="CP.Extensions.Hosting.Wpf" Version="3.1.26" />
<PackageVersion Include="CP.Extensions.Hosting.Wpf" Version="3.1.26" />Directory.Packages.props
<PackageReference Include="CP.Extensions.Hosting.Wpf" />Project file
paket add CP.Extensions.Hosting.Wpf --version 3.1.26
#r "nuget: CP.Extensions.Hosting.Wpf, 3.1.26"
#:package CP.Extensions.Hosting.Wpf@3.1.26
#addin nuget:?package=CP.Extensions.Hosting.Wpf&version=3.1.26Install as a Cake Addin
#tool nuget:?package=CP.Extensions.Hosting.Wpf&version=3.1.26Install as a Cake Tool
NOTE: The namespacing has been changed to ReactiveMarbles.Extensions.Hosting. Please update your references to the new namespace.
Extensions for Microsoft.Extensions.Hosting that bring WPF, WinForms, WinUI, ReactiveUI, plug-ins, single-instance control, and common host utilities to desktop apps.
This repository supports both classic IHostBuilder and the newer IHostApplicationBuilder hosting model introduced in .NET 8+. Existing IHostBuilder APIs remain unchanged; equivalent IHostApplicationBuilder overloads are available where appropriate.
Supported targets include .NET Framework 4.6.2/4.8, .NET Standard 2.0, and .NET 8/9/10 (Windows where applicable).
Choose a hosting model:
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.Wpf;
var host = Host.CreateDefaultBuilder(args)
.ConfigureWpf(wpf =>
{
// Optional: register Application type and windows via the WpfBuilder
wpf.ApplicationType = typeof(App);
wpf.WindowTypes.Add(typeof(MainWindow));
wpf.ConfigureContextAction = ctx => ctx.ShutdownMode = ShutdownMode.OnMainWindowClose;
})
.UseWpfLifetime(ShutdownMode.OnMainWindowClose)
.Build();
await host.RunAsync();
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.Wpf;
var builder = Host.CreateApplicationBuilder(args)
.ConfigureWpf(wpf =>
{
wpf.ApplicationType = typeof(App);
wpf.WindowTypes.Add(typeof(MainWindow));
wpf.ConfigureContextAction = ctx => ctx.ShutdownMode = ShutdownMode.OnMainWindowClose;
})
.UseWpfLifetime(ShutdownMode.OnMainWindowClose);
await builder.Build().RunAsync();
The following sections outline the main features, their APIs for both hosting models, and example usage.
Namespace: ReactiveMarbles.Extensions.Hosting.Wpf
Example (builder model): see Quick start above.
Namespace: ReactiveMarbles.Extensions.Hosting.WinForms
Example (application builder):
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.WinForms;
var builder = Host.CreateApplicationBuilder(args)
.ConfigureWinForms(ctx =>
{
ctx.EnableVisualStyles = true;
})
.ConfigureWinFormsShell<MainForm>()
.UseWinFormsLifetime();
await builder.Build().RunAsync();
Namespace: ReactiveMarbles.Extensions.Hosting.WinUI
Example (application builder):
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.WinUI;
var builder = Host.CreateApplicationBuilder(args)
.ConfigureWinUI<App, MainWindow>();
await builder.Build().RunAsync();
Namespaces: ReactiveMarbles.Extensions.Hosting.ReactiveUI (per UI stack)
Example (WPF + ReactiveUI with application builder):
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.ReactiveUI;
using ReactiveMarbles.Extensions.Hosting.Wpf;
var builder = Host.CreateApplicationBuilder(args)
.ConfigureSplatForMicrosoftDependencyResolver()
.ConfigureWpf(wpf =>
{
wpf.ApplicationType = typeof(App);
wpf.WindowTypes.Add(typeof(MainWindow));
})
.UseWpfLifetime();
await builder.Build().RunAsync();
Namespace: ReactiveMarbles.Extensions.Hosting.Plugins
Example (application builder):
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.Plugins;
var builder = Host.CreateApplicationBuilder(args)
.ConfigurePlugins(plugins =>
{
plugins.UseContentRoot = true;
// Add framework assemblies and plugin patterns
plugins.IncludeFrameworks(@"\\netstandard2.0\\*.FrameworkLib.dll");
plugins.IncludePlugins(@"\\Plugins\\{runtime}\\ReactiveMarbles.Plugin.*.dll");
});
await builder.Build().RunAsync();
Namespace: ReactiveMarbles.Extensions.Hosting.AppServices
Example (application builder):
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.AppServices;
var builder = Host.CreateApplicationBuilder(args)
.ConfigureSingleInstance(cfg =>
{
cfg.MutexId = "{ea031523-3a63-45e5-85f2-6fa75fbf37ed}";
cfg.WhenNotFirstInstance = (env, logger) =>
logger.LogWarning("Application {0} already running.", env.ApplicationName);
});
await builder.Build().RunAsync();
Namespace: ReactiveMarbles.Extensions.Hosting.PluginService
Example (service/console dual mode using IHostApplicationBuilder):
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.PluginService;
var builder = Host.CreateApplicationBuilder(args)
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureLogging()
.ConfigureConfiguration(args)
.UseConsoleLifetime(); // or .UseServiceBaseLifetime() for Windows Service
await builder.Build().RunAsync();
Example (helper):
using ReactiveMarbles.Extensions.Hosting.PluginService;
await ServiceHost.CreateApplication(
typeof(Program),
args,
hb => hb // external builder customization
.ConfigurePlugins(pb =>
{
/* plugin globs */
pb.RequirePlugins(true); // fail if none found - optional default false
}),
host => { /* use host.Services */ },
nameSpace: "ReactiveMarbles.Plugin");
Namespaces:
APIs (service collection extensions used inside UseWebHostServices):
Host/web host wiring:
Example:
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using ReactiveMarbles.Extensions.Hosting.Identity.EntityFrameworkCore;
var host = Host.CreateDefaultBuilder(args)
.UseWebHostServices((whb, services) =>
{
services.UseEntityFrameworkCoreSqlServer<AppDbContext, IdentityUser, IdentityRole>(whb, "DefaultConnection");
})
.Build();
await host.RunAsync();
var builder = Host.CreateApplicationBuilder(args)
.ConfigureSplatForMicrosoftDependencyResolver()
.ConfigureWpf(wpf =>
{
wpf.ApplicationType = typeof(App);
wpf.WindowTypes.Add(typeof(MainWindow));
})
.UseWpfLifetime()
.ConfigureSingleInstance("{ea031523-3a63-45e5-85f2-6fa75fbf37ed}");
await builder.Build().RunAsync();
.ConfigurePlugins(pluginBuilder =>
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Running using dotNet {0}", Environment.Version);
var process = Process.GetCurrentProcess();
var fullPath = process.MainModule?.FileName?.Replace(process.MainModule.ModuleName!, string.Empty);
Console.WriteLine("Add Scan Directories: {0}", fullPath);
pluginBuilder?.AddScanDirectories(fullPath!);
pluginBuilder?.IncludeFrameworks(@"\netstandard2.0\*.FrameworkLib.dll");
var runtime = Path.GetFileName(AppContext.BaseDirectory);
Console.WriteLine(@"Include Plugins from: \Plugins\{0}\{1}*.dll", runtime, "ReactiveMarbles.Plugin");
pluginBuilder?.IncludePlugins(@$"\Plugins\{runtime}\{{YourPluginNamespace}}*.dll");
Console.ResetColor();
})
await ServiceHost.Create(
typeof(Program),
args,
hb => hb, // Configure the HostBuilder
host => {}, // Configure the Host
nameSpace: "ReactiveMarbles.Plugin").ConfigureAwait(false);
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 net8.0-windows7.0 is compatible. net9.0-windows net9.0-windows was computed. net9.0-windows7.0 net9.0-windows7.0 is compatible. net10.0-windows net10.0-windows was computed. net10.0-windows7.0 net10.0-windows7.0 is compatible. |
| .NET Framework | net462 net462 is compatible. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 is compatible. net48 net48 was computed. net481 net481 is compatible. |
Showing the top 1 NuGet packages that depend on CP.Extensions.Hosting.Wpf:
| Package | Downloads |
|---|---|
|
CP.Extensions.Hosting.ReactiveUI.Wpf
This extension adds ReactiveUI support to generic host based dotnet core 8.0 / 9.0 / 10.0 WPF applications. With this you can enhance your application with a UI, and use all the services provided by the generic host like DI, logging etc, together with this reactive MVVM framework. |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.1.26 | 423 | 5/5/2026 |
| 3.1.6 | 649 | 4/21/2026 |
| 3.1.2 | 122 | 4/21/2026 |
| 3.0.9 | 166 | 4/9/2026 |
| 3.0.6 | 168 | 3/12/2026 |
| 3.0.4 | 161 | 3/8/2026 |
| 3.0.0-beta.10 | 87 | 1/22/2026 |
| 2.3.15 | 1,104 | 12/2/2025 |
| 2.3.13 | 633 | 12/1/2025 |
| 2.3.4 | 289 | 11/3/2025 |
| 2.3.3 | 255 | 11/3/2025 |
| 2.2.2 | 615 | 9/10/2025 |
| 2.1.13 | 1,291 | 4/29/2025 |
| 2.1.10 | 318 | 3/16/2025 |
| 2.1.8 | 296 | 2/19/2025 |
| 2.1.6 | 244 | 2/9/2025 |
| 2.1.4 | 311 | 11/21/2024 |
| 2.0.5 | 491 | 5/18/2024 |
| 1.5.2 | 237 | 5/17/2024 |
| 1.4.2 | 284 | 5/5/2024 |
Compatability with Net 8 / 9 / 10 and net462 / net472 / net481