-
Notifications
You must be signed in to change notification settings - Fork 474
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
Question: How to add Autofac to LambdaEntryPoint in net core 3.0? #616
Comments
I am also having issues (.NET Core 3.1) with this and do not have the option of replacing Lambda as the DI provider. My LocalEntryPoint class is simple and shown below, however this seems impossible to wire up in the LambdaEntryPoint class. public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args)
{
return Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder => { webBuilder .UseStartup<Startup>(); });
} normj edited formatting of code to make readable. |
Yeah I see now the continual use if IWebHostBuilder is a blocker for using Autofac in .NET Core 3.1. Sorry I should have switched to IHostBuilder as part of the major version change that went out with .NET Core 3.1. I was trying to avoid complexity with this library also supporting .NET Core 2.1 which does use IWebHostBuilder. I don't want to make significant set breaking changes just a couple weeks after the last major version came out so let me think if there is a less invasive approach to unblock you all. |
I have created PR #633 to switch to IHostBuilder unless the function overrode the |
Version 5.1.0 of I also published a blog post that has a section describing the change. |
I am not sure, if this was the cause, but I had a regression between 5.0.0 and 5.1.1. I made a comment, in another Issue: #669 (comment) with the Stacktrace. My project can be found at github. My Entrypoint has this lines, which wil cause the problems (I think):
|
Hi @Xocix, Please advise if using the latest version resolves the issue. Thanks, |
Hey @ashishdhingra sorry for not responding. For me the latest version resolved the issue, thanks everyone involved, i am happy with the result! |
Hi,
I am testing out an api project with Amazon.Lambda.AspNetCoreServer and i stumbled upon a problem which i am not sure how to proceed with.
Autofac has changed how its added:
New way: With IHostBuilder
.UseServiceProviderFactory(new AutofacServiceProviderFactory()
Old Way: With IWebHostBuilder
serviceCollection.AddAutofac()
Also from my understanding IWebHostBuilder will be deprecated which LambdaEntryPoint is using in the Init method.
For the IWebHostBuilder when i try to add Autofac i get this info message from the method:
And i cant use IHostBuilder with LambdaEntryPoint.
Anyone has done this or has any ideas how to proceed? Thanks in advance!
The text was updated successfully, but these errors were encountered: