首页 > 解决方案 > .Net Core The name 'Host' does not exist

问题描述

I'm busy trying to get a .Net Core Host running but I keep getting a compiler error

error CS0103: The name 'Host' does not exist in the current context

I don't know if I am missing an import or package that is causing this but I am using .net core 5.0.402, the only package I added was Microsoft.AspNetCore

using System;
using System.Data;
using System.Dynamic;
using System.Collections.Generic;

using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace TemporaryNamespace {

    public class HostClass {

        public HostClass(string[] args, string url, string port) {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args);

    }

}

I'm compiling on Debian 10 by the way, I don't know if that makes a difference.

标签: .net-coredependencieshost

解决方案


推荐阅读