开发者

The intended purpose for <app name>.exe.config file in a VB.NET Forms app

开发者 https://www.devze.com 2023-01-16 20:09 出处:网络
I a开发者_JS百科m currently reading up on documentation for a possible assignment I might be put on. In a design document they talk about the .exe.config file. They state that its only purpose is to s

I a开发者_JS百科m currently reading up on documentation for a possible assignment I might be put on. In a design document they talk about the .exe.config file. They state that its only purpose is to store constants:

"Also note that this file is meant to store constants only, it is not meant to write configuration values to (and the .NET 1.1. framework even prevents this by not offering classes/methods to do so). Therefore, configuration is written to XML files using a..."

As far as I understand, this is not true. I don't know about .NET 1.1 preventing this, but I remember in my last project that I did write configuration values to that file (I saved GUI contents there). My project was a small prototype, so maybe I did it wrong, but I do not think so...

So what is the intended purpose of this file?

Thanks in advance.


No, that's accurate. Note the Scope column in the Setting Designer. "Application" is used for setting values that go into app.exe.config. "User" should be used for settings that can be modified and saved back. They go in a separate file named user.config which is stored in a subdirectory of AppData.

It needs to work this way because you normally need admin privileges to modify the app.exe.config file. It must be stored in the same directory as the EXE. The normal install location (c:\program files\something) is read-only for restricted user accounts or admin accounts with UAC turned on.


While you can edit the contents of the config file, it's not generally a good idea to do so. That file is for configuration information, as opposed to profile/settings information. There are other APIs for that type of data in .NET 2+


You store settings there. This is a wide concept, a lot of things can be considered settings. Constants, connection strings, credentials and even GUI layout. Any XML data actually.

0

精彩评论

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

关注公众号