Skip to content

IWebHostEnvironment missing in RegisterFactory container #81

Open
@arian2ashk

Description

@arian2ashk

Hi, When I use unityContainer.Resolve<IWebHostEnvironment>(); on the main container it resolve it and return a value but if I use the following code and resolve IWebHostEnvironment from child container it throws exception:

unityContainer.RegisterFactory<someType>(c =>
      {
        var iWeb = c.Resolve<IWebHostEnvironment>();
        return new someType(iWeb);
      }, new SingletonLifetimeManager());

The exception:

Unity.ResolutionFailedException: 'Resolution failed with error: No public constructor is available for type Microsoft.AspNetCore.Hosting.IWebHostEnvironment.

Why Asp.net core services are not accessible in the factory?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions