Thiya
Thiya

Reputation: 75

Latest Autofac version Doesn't support .Net Framework 4.6.2

My project is a cross platform project. Which contains 3 Project 2 .Net-standard 2.0 and one startup project with .Net-framework 4.6.2.

The latest Autofac version(5.2.0) is not supporting .NetFramework 4.6.2.

I have encountered the error

autofac.core.registration.componentnotregisteredexception' in autofac.dll" builder.Build() couldn't instantiate the class object.

Error message:

An exception of type 'Autofac.Core.Registration.ComponentNotRegisteredException' occurred in Autofac.dll but was not handled in user code Additional information: The requested service 'ShipPageObjects.PageObjects.Login.LoginResolvePage' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.

var builder = new ContainerBuilder();
builder.RegisterModule(new ContainerConfig());
builder.RegisterInstance(testConfig).As<ITestConfig>();
builder.RegisterModule(new ShipmentmentTest(testConfig));
builder.RegisterModule(new MaterialTest(testConfig));

Container = builder.Build();

Upvotes: 2

Views: 1603

Answers (1)

Corv1nus
Corv1nus

Reputation: 4625

This is not an error with Autofac 5.2.0 and .NET Framework 4.6.2. In the exception it's telling you that the ShipPageObjects.PageObjects.Login.LoginResolvePage is not registered. It's likely that you're injecting it into something that you have registered and you haven't registered the LoginResolvePage.

Autofac is really good at telling you what is failing in these instances. You can either 1 by 1 go through and look at the exceptions and add as it tells you what needs added, or trace your injection back through and make sure everything is registered. I would recommend doing the latter and using the former to finish it up.

Upvotes: 3

Related Questions