![]() |
VOOZH | about |
dotnet add package CP.Extensions.Hosting.ReactiveUI.Avalonia --version 3.1.26
NuGet\Install-Package CP.Extensions.Hosting.ReactiveUI.Avalonia -Version 3.1.26
<PackageReference Include="CP.Extensions.Hosting.ReactiveUI.Avalonia" Version="3.1.26" />
<PackageVersion Include="CP.Extensions.Hosting.ReactiveUI.Avalonia" Version="3.1.26" />Directory.Packages.props
<PackageReference Include="CP.Extensions.Hosting.ReactiveUI.Avalonia" />Project file
paket add CP.Extensions.Hosting.ReactiveUI.Avalonia --version 3.1.26
#r "nuget: CP.Extensions.Hosting.ReactiveUI.Avalonia, 3.1.26"
#:package CP.Extensions.Hosting.ReactiveUI.Avalonia@3.1.26
#addin nuget:?package=CP.Extensions.Hosting.ReactiveUI.Avalonia&version=3.1.26Install as a Cake Addin
#tool nuget:?package=CP.Extensions.Hosting.ReactiveUI.Avalonia&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 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
Showing the top 1 NuGet packages that depend on CP.Extensions.Hosting.ReactiveUI.Avalonia:
| Package | Downloads |
|---|---|
|
CrissCross.Avalonia.UI
A Reactive Navigation Framework for ReactiveUI |
This package is not used by any popular GitHub repositories.
Compatability with Net 8 / 9 / 10 and net462 / net472 / net481