-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better Integration to Generic Host #391
Comments
For existing applications. 1. Replace Serilog in the .csproj fileOld code: <PackageReference Include="Serilog.AspNetCore" Version="2.1.1" /> New code: <PackageReference Include="Serilog.Extensions.Hosting" Version="3.0.0" /> 2. Update Program.csOld code: public static IWebHost BuildWebHostInternal(string[] args) =>
new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIIS()
.UseIISIntegration()
.UseStartup<Startup>()
.UseSerilog()
.Build(); New code: internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog(); Also change 3. Update Startup.csOld code: public class Startup
{
public IServiceProvider ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameHttpApiHostModule>(options =>
{
options.UseAutofac();
});
return services.BuildServiceProviderFromFactory();
}
public void Configure(IApplicationBuilder app)
{
app.InitializeApplication();
}
} New code: public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameHttpApiHostModule>();
}
public void Configure(IApplicationBuilder app)
{
app.InitializeApplication();
}
} |
Halil,
Is not possible to call context.Services.GetContainerBuilder() from AbpModule.ConfigureServices() |
Try calling
|
@maliming, in that way gives me another exception. here is the stacktrace:
|
hi @lommez |
here is the program.cs
here is the startup.cs
|
The code you should update your
see #391 (comment) |
Thanks @maliming The problem was calling services.BuildServiceProviderFromFactory() within Startup.ConfigureServices() When removed that method everything works fine |
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host?view=aspnetcore-2.1
The text was updated successfully, but these errors were encountered: