C
C#3y ago
Servator

App.Config vs Resources.resx [Answered]

What's the main difference between them also why App.Config considered more secure approach ? 2nd question: Can i store type values with App.Config like ConsoleColor.Red ?
8 Replies
Servator
ServatorOP3y ago
bump
Mayor McCheese
app.config would store settings about your application from an execution standpoint, it's not particularly secure, especially for a client app. You have prebuilt structures for things like connection strings A resource file is typically used to store information about your application from a usage perspective, label fields, etc. There is a whole system for resource files in different languages for instance.
Servator
ServatorOP3y ago
Also there is AppSettings I am really confused about those What would you prefer ?
Mayor McCheese
AppSettings.json? App.Config is pretty rigid and in code has a lot of static helper classes, I don't personally like it, people tend to use ConfigurationManager class like it's going out of style and I think it promotes bad coding practices.
Servator
ServatorOP3y ago
There is type safety issue too
Mayor McCheese
for example:
class Something
{
string GetData()
{
var value = ConfigurationManager.AppSettings["SomeKey"];
return value;
}
}
class Something
{
string GetData()
{
var value = ConfigurationManager.AppSettings["SomeKey"];
return value;
}
}
I have no way to track usage of "SomeKey", other than searching code. I always advise not to use something like ConfigurationManager directly, but to build facades over it with AppSettings.json this is much easier to do.
Servator
ServatorOP3y ago
ok thanks
Accord
Accord3y ago
✅ This post has been marked as answered!
Want results from more Discord servers?
Add your server