UnityContainer不会沿着所有异常路径警告处理

时间:2017-10-12 10:48:34

标签: c# .net idisposable

请你帮我一个警告:

 Warning    CA2000  In method 'UnityConfig.UnityConfig()', object 'container' 
 is not disposed along all exception paths. Call System.IDisposable.Dispose on 
 object 'container' before all references to it are out of scope.

我的代码:

private static Lazy<IUnityContainer> container = new 
Lazy<IUnityContainer>(() =>
    {
        var container = new UnityContainer();
        RegisterTypes(container);
        return container;
    });

我有UnityWebApiActivator类和方法:

public static void Shutdown()
{
    var container = UnityConfig.GetConfiguredContainer();
    container.Dispose();
}

0 个答案:

没有答案