NetEvolve.Extensions.Hosting.WinForms 1.1.23

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

// Install NetEvolve.Extensions.Hosting.WinForms as a Cake Tool
#tool nuget:?package=NetEvolve.Extensions.Hosting.WinForms&version=1.1.23                

NetEvolve.Extensions.Hosting.WinForms

Nuget Nuget

The main purpose of this package is to provide a way to use the Microsoft.Extensions.Hosting for WinForms applications, allowing the use of dependency injection, configuration, logging, and other features provided by the Microsoft.Extensions libraries.

💡 This package is available for .NET 6.0 and later.

Installation

To use this package, you need to add the package to your project. You can do this by using the NuGet package manager or by using the dotnet CLI.

dotnet add package NetEvolve.Extensions.Hosting.WinForms

Usage

To use the Microsoft.Extensions.Hosting in a WinForms application, you just need to create a new HostBuilder and configure it as you would do in a console application.

namespace WinForms;

using Microsoft.Extensions.Hosting;
using NetEvolve.Extensions.Hosting.WinForms;

internal static class Program
{
    internal static async Task Main() =>
        await CreateHostBuilder().Build().RunAsync().ConfigureAwait(false);

    public static IHostBuilder CreateHostBuilder() =>
        Host.CreateDefaultBuilder().UseWindowsForms<Form1>();
}

Therefore, you can use for example the Microsoft.Extensions.DependencyInjection to register services and inject them into your forms.

namespace WinForms;

using Microsoft.Extensions.DependencyInjection;
using System.Windows.Forms;

public partial class Form1 : Form
{
    private readonly ILogger<Form1> _logger;

    public Form1(ILogger<Form1> logger)
    {
        _logger = logger;
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
        _logger.LogInformation("Form loaded.");
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0-windows7.0 is compatible.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0-windows was computed.  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
1.3.0 85 11/17/2024
1.2.55 111 9/12/2024
1.2.43 128 8/26/2024
1.2.0 127 5/23/2024
1.1.23 121 5/21/2024
1.1.5 133 4/8/2024
1.1.0 126 4/4/2024
1.0.1 102 3/29/2024