简体   繁体   中英

How can I check if configuration file is proper?

有什么方法可以在.net中检查我的配置文件(我提供自己的配置)是否正确,而无需根据Xml Schema对其进行验证?

Have a look in the System.Configuration namespace. There is a class for reading the config settings which does this for you without great effort.

I'm fairly sure that the AppSettingsReader class will give you some good validation techniques. I usually just use the boilerplate code provided by the app settings in visual studio to do this though, if the file is invalid then the system will fall back onto defaults.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM