Unity依赖注入-DependencyResolver.current.GetService()为Web API返回null

时间:2019-01-09 01:27:22

标签: unity3d dependency-injection

我在WebAPIConfig中具有以下内容, var container = new UnityContainer();              RegisterTypes(容器);

          config.DependencyResolver = new UnityResolver(container);
        GlobalConfiguration.Configuration.DependencyResolver = new UnityResolver(container);

我需要访问DependencyResolver.current.GetService(),但它返回null。您能否建议在WebAPIConfig级别上进行哪些更改才能在其他位置访问DependencyResolver.current?

0 个答案:

没有答案