AlexBins.Hosting.Wpf 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package AlexBins.Hosting.Wpf --version 2.0.0                
NuGet\Install-Package AlexBins.Hosting.Wpf -Version 2.0.0                
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="AlexBins.Hosting.Wpf" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AlexBins.Hosting.Wpf --version 2.0.0                
#r "nuget: AlexBins.Hosting.Wpf, 2.0.0"                
#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 AlexBins.Hosting.Wpf as a Cake Addin
#addin nuget:?package=AlexBins.Hosting.Wpf&version=2.0.0

// Install AlexBins.Hosting.Wpf as a Cake Tool
#tool nuget:?package=AlexBins.Hosting.Wpf&version=2.0.0                

Hosting.Wpf

What is it used for?

This library adds WPF support to Microsoft.Extensions.Hosting.

How do I use it?

You configure your host to use WPF and add Window instances as required. Then you use the provided extension method to run the application.

class Program {
  
  static int Main(string[] args) {
    var builder = new HostBuilder()
        .AddWpf<App>()
        .UseSerilog((ctx, svc, config) =>
            config
            .WriteTo.Console()
            .Enrich.FromLogContext()
            .MinimumLevel.Debug())
        .ConfigureServices((ctx, svc) =>
        {
            // Services registered as Window will be shown on app start
            svc.AddSingleton<Window, MainWindow>();
        });

    var host = builder.Build();
    var logger = host.Services.GetRequiredService<ILogger<Program>>();
    try
    {
        await host.RunAsync();
    }
    catch (Exception ex)
    {
        logger.LogCritical(ex, "Host terminated unexpectedly");
        return -1;
    }
    return 0;
  }
}
Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
2.1.1 150 4/8/2024
2.1.0 131 3/11/2024
2.0.0 126 3/11/2024
1.0.0 277 8/22/2022 1.0.0 is deprecated because it is no longer maintained.