I am attempting to make a new project that is dependent on some old libraries. Those libraries are using Unity for dependency injection. They are also using the Property Injection with the DependencyAttribute. My new project is a ASP.NET Core 2.1 application using the provided Angular Template. I have configured it for unity doing the following:
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
var container = /* calls internal method to get container */;
return WebHost.CreateDefaultBuilder(args)
.UseUnityServiceProvider(container)
.UseStartup<Startup>();
}
The container is created in an internal library and works fine everywhere else.
When I use Constructor Injections the services are injected correctly, however using the Property Injection does not work. All properties injected in this way end up NULL. Any ideas how to get Property Injection to work?
Constructor Injection (works):
private readonly IServiceA ServiceA;
public ControllerA(IServiceA serviceA)
{
this.ServiceA = serviceA;
}
Property Injection (doesn't work):
[Dependency]
public IServiceA ServiceA { get; set; }