将核心2.2迁移到3.0时,出现错误“不支持System.IServiceProvider”

时间:2019-09-27 09:41:37

标签: c# entity-framework-core .net-core-3.0 ef-core-3.0

控制台中的错误是: ConfigureServices返回System.IServiceProvider。

迁移之前(Asp.net Core 2.2)

 public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .ConfigureLogging(options => options.ClearProviders())
                .UseNLog()
                .UseStartup<Startup>();

迁移后(Asp.net Core 3.0)


 public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(serverOptions =>
                    {
                    // Set properties and call methods on options
                })
                    .UseNLog()
                    .UseStartup<Startup>();
                });
public static void Main(string[] args)
        {
            var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
            try
            {
                logger.Debug("init main");
                CreateHostBuilder(args).Build().Run();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Stopped program because of exception");
                throw;
            }
            finally
            {
                segmentation fault on Linux)
                NLog.LogManager.Shutdown();
            }
        }

0 个答案:

没有答案