开发者

Do you need to "close" .net Configuration

开发者 https://www.devze.com 2023-03-09 14:37 出处:网络
When you create a co开发者_Python百科nfiguration object to manage .net configuration files, do you need to close the files.

When you create a co开发者_Python百科nfiguration object to manage .net configuration files, do you need to close the files.

I have an application with several .dll components. Do I have to use a global config to avoid keep writing over changes being done by other .dll's to the same configuration file.

Public Shared config As System.Configuration.Configuration 
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
....do config entries here.
config.save

Do I know need to close/dispose this config before making changes to the same configuration file from another module.


No, you don't need to Close/Dispose. The Configuration class returned by the OpenExeConfiguration static method doesn't implement IDisposable nor it has any Close method so your code is fine.

0

精彩评论

暂无评论...
验证码 换一张
取 消