modular-monolith-with-ddd icon indicating copy to clipboard operation
modular-monolith-with-ddd copied to clipboard

After Migrating in to .Net 3.1 Failing to hit LoggingCommandHandlerDecorator

Open saiprabhur opened this issue 4 years ago • 6 comments

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.

saiprabhur avatar May 29 '20 14:05 saiprabhur

The current solution is already on 3.1. Why don't you just pull that instead.

kacey90 avatar May 29 '20 23:05 kacey90

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.

kgrzybek avatar May 30 '20 19:05 kgrzybek

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.

saiprabhur avatar May 31 '20 02:05 saiprabhur

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 avatar May 31 '20 08:05 kacey90

@kacey90 , a possible solution to work with autofac 5 can be found here #75 .

stone9988 avatar Jun 09 '20 16:06 stone9988

Thanks @stone9988 for the alternative until autofac fix the issue.

One more alternative decorator to be called using pipeline behaviour apporach.

saiprabhur avatar Jul 22 '20 05:07 saiprabhur