Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

ASP.NET Core View Injection problems

$
0
0

Has anyone tried to use the new View Injection from ASP.NET Core?

I'm trying to use straight forward as described on the documentation (https://docs.asp.net/en/latest/mvc/views/dependency-injection.html) but no success at all.

The unique diference from my implementation and the documentation is that I'm using AutoFac for DI. When I try to use the injection on my view I get an exception that my Service has not been registered.

@inject Domain.Service.LevelService LevelService

Error Message:

ComponentNotRegisteredException: The requested service 'Domain.Service.LevelService' 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.

Btw, the service is correctly registered and can be accessed from inside the controller for example.

Thanks!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>