modular-monolith-with-ddd
modular-monolith-with-ddd copied to clipboard
After Migrating in to .Net 3.1 Failing to hit LoggingCommandHandlerDecorator
Changed Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() and changed the Startup class to
from:private IServiceProvider CreateAutofacServiceProvider(IServiceCollection services) to: public void ConfigureServices(IServiceCollection services)
and removed CreateAutofacServiceProvider(services) instead of that i used. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
to initialize the module from above configure method. public void ConfigureContainer(ContainerBuilder containerBuilder) To register Autofacmodules.
IComponentRegister doesnt contains GenericDecorator e.g. LoggingDecorator ,ValidationDecorator...
What could be the issue.
The current solution is already on 3.1. Why don't you just pull that instead.
Hi @saiprabhur
It is hard to tell what is the problem based on your description.
As @kacey90 mentioned, the whole application is on the .NET Core 3.1 already and it works, so maybe use configuration from this project.
Thanks for the reply. i have spent time the above details is not cause of the issue. after upgrading Autofac to newer version. the generic decorator handler failed to call. (loggerhandlerdecorator..) the command goes directly to the command handler.
i could not figured out why its failing after upgrade of Autofac.
I see what @saiprabhur is saying here. As a matter of fact, I just figured it was my the problem I was facing all along and didn't know. I was also using the latest versions of autofac and autofac.extensions.dependencyInjection. This was preventing the decorators (UnitOfWork, Logging and validation) from being called when they are needed. I went to autofac's repo to discover that the new versions (>= 5.1.0) have some breaking changes as they were trying to fix something about registration of decorators. Maybe @kgrzybek can take a look and see how it impacts this codebase.
What I had to do was to downgrade the related nuget packages and my code is working as it should now.
@kacey90 , a possible solution to work with autofac 5 can be found here #75 .
Thanks @stone9988 for the alternative until autofac fix the issue.
One more alternative decorator to be called using pipeline behaviour apporach.