First of all, I am aware that this error is very generic and there exists many such posts with similar error on stack overflow but still I am unable to overcome this issue. First of all the strange situation is: This issue doesn't happen in my local system but when code is deployed to a container in QA environment then this following error starts occurring:
System.InvalidOperationException Error constructing handler for request of type Mediat.RequestHandler 2[Appl icationServices.ConnectToTargetEnvironment.ConnectToTargetEnvironmentCommand, ApplicationServices.ConnectToTargetEnvironment.ConnectToTargetEnvironmentResponse). Register your handlers with the container
We are using Autofac and Mediatr packages in our solution and I feel issue falls more towards Autofac after looking at the exception. The other strange scenario is this excpetion occurs only with the 'ConnectToTargetEnvironmentHandler' and other handlers work just fine in QA.
'GetTargetEnvironmentsHandler' works just fine in QA but the 'ConnectToTargetEnvironmentHandler' throws the above mentioned exception in QA.
I have tried the following things but that didn't yield me any positive results:
builder.RegisterType<ConnectToTargetEnvironmentHandler>().As<IRequestHandler<ConnectToTargetEnvironmentCommand, ConnectToTargetEnvironmentResponse>>().InstancePerLifetimeScope();where builder isContainerBuildertype.services.AddMediatR(AppDomain.CurrentDomain.GetAssemblies()); services.AddMediatR(typeof(ConnectToTargetEnvironmentCommand).GetTypeInfo().Assembly); services.AddMediatR(typeof(ConnectToTargetEnvironmentResponse).GetTypeInfo().Assembly);where services isIServiceCollectioncontract.
What might be wrong or How can I fix this issue which is occurring just on QA??.
