不使用X509Store.Close方法意味着什么? [英] What is the implication of not using X509Store.Close method?

查看:37
本文介绍了不使用X509Store.Close方法意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我继续初始化 X509Store 证书存储,请不要使用其

If I keep initializing X509Store certificate stores and don't use their Close() method, what is the implication of this?

在代码示例在文档中,他们没有使用 try..finally 块来调用 Close 方法.如果此证书存储区需要释放,为什么设计用于从 IDisposable 派生的类的API或为什么当对象超出范围时此类没有隐式析构函数被调用?

In the code example given in documentation, they don't use try..finally block to make a call to Close method. If this certificate store is something that needs to be freed, why does not the API of the class designed to derive from IDisposable or why does not this class have a implicit destructor called when object goes out of scope?

推荐答案

在.NET 4.6中,对 X509Store 进行了修改,现在实现了 IDisposable .

In .NET 4.6, X509Store was modified and now implementing IDisposable.

Dispose 实现正在调用 Close().

来自 Microsoft Docs

From Microsoft Docs:

从.NET Framework 4.6开始,此类型实现IDisposable接口.使用完该类型后,应直接或间接处理它.

Starting with the .NET Framework 4.6, this type implements the IDisposable interface. When you have finished using the type, you should dispose of it either directly or indirectly.

这篇关于不使用X509Store.Close方法意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆