Migrating from AutoFac to Unity, cannot get Services DI working again - seeking assistance. #186
Unanswered
Eclipse-Computing
asked this question in
Q&A
Replies: 1 comment
-
I used to use Unity and don't recommend it's use over Autofac. It's slower and has fewer updates. Autofac has specific helpers to help with registering MVC types which Unity does not provide. See https://github.com/ASP-NET-Core-Boilerplate/Templates/blob/before-removing-vsix/Source/MVC5/Boilerplate.Web.Mvc5.Sample/App_Start/Startup.Container.cs |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using the ASP.NET MVC 5 boilerplate, Visual Studio 2017 Community.
When I switch the DI from AutoFac to Unity, I am unable to get the Services (robots.txt, sitemap.xml) back up and running. In particular, I am unable to translate the Autofac entries for these services to the appropriate Unity entries.
My HomeController default constructor is unchanged from the default, at least for robots.txt, which I am doing the litmus test on:
private readonly IRobotsService _robotsService;
public HomeController(
IRobotsService robotsService
) {
_robotsService = robotsService;
}
When my UnityConfig.cs file has the following:
container.RegisterType<RobotsService>(new TransientLifetimeManager());
I get
When my UnityConfig file has the following:
container.RegisterType<IRobotsService, RobotsService>(new TransientLifetimeManager());
I get
Any assistance would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions