简体   繁体   中英

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();

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM