Skip to content
Application builder library for .NET Framework Windows Forms and Console Applications, inspired by .NET Core
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

NuGet License


Application builder library for .NET Framework Windows Forms and Console Applications, inspired by .NET Core

CoreUi is built to bring ASP.NET Core dependancy injection and host builder pattern to any .NET standard application.

CoreUi can be used in console or Windows Forms applications built with .NET Framework 4.6.1+ or with .NET Core console applications.


Simple console application

AppHostBuilder is used to prepare the application. The action passed to the Run() method is executed by the host.

    class Program
        static void Main(string[] args) =>
            new AppHostBuilder().Build().Run(app => Console.WriteLine("Hello World!"));

Console application

Services and command-line arguments are registered at the AppHostBuilder. To use them, IAppHost app is provided by the host in the Run() lambda function.

    static void Main(string[] args)
        IAppHost host = new AppHostBuilder()
            .ConfigureServices(s => s.AddSingleton<IDemo, Demo>() )

        host.Run(app =>
            var demo = app.Services.GetRequiredService<IDemo>();
            app.Arguments.ToList().ForEach(arg => Console.WriteLine(arg));

Using a Startup class

Implement interface IStartup from Vhc.CoreUi.Abstractions from your startup class, and register the startup class in AppHostBuilder instance.


    class Startup : IStartup
        // Register the configuration files
        public void Configure(IConfigurationBuilder config)
            config.AddJsonFile("appsettings.json", optional: true);
        // Register services for dependancy injection
        public void ConfigureServices(IServiceCollection services)
        // Start point of the application, this is called by Run() method of the application host
        public void Start(IAppHost app)
            var foo = app.Services.GetService<Foo>();


    static void Main(string[] args)
        new AppHostBuilder()

As the ASP.NET Core ServiceCollection used in ConfigureServices, you can use any suitable library here. For example, Sqlite can be used alongwith Entity Framework Core.

public void ConfigureServices(IServiceCollection services)
        services.AddDbContext<MyDbContext>(options =>
You can’t perform that action at this time.