Question Where is the best place to store messages?

Greedyh4mster

Member
Joined
Aug 12, 2010
Messages
6
Programming Experience
Beginner
Hiya!

I am wondering where should I store my error messages. These messages are the simplified version meant for the users. I am thinking like centralizing a specific location to store all the custom messages so that it will be easier to reference in the future. The location should also provide a key for each stored message.

For instance, I can think of using the me.settings to store all the messages. But I am wondering whether is it the best place? What is the best practice for such action? :confused:

Update:
The more accurate intention of what I am trying to say in the above is; For example:
VB.NET:
Msgbox "You have encountered an error!"
Msgbox "Invalid login details!"

Right now, I have the above messages embed inside the form itself. What I need will be similar to:

VB.NET:
Msgbox errorMessage("generic")
Msgbox errorMessage("login_invalid")

Something like a place or a variable collections with keys, to store all the messages that are in the form. Based on the reply below, I am thinking of storing every messages with the key into a file that when the form is loading; The form will parse the file and stored them into a global variable as hashtable. But would that be the best practice? :rolleyes:
 
Last edited:
Store an error log file under the Program Data folder. To get the path of that folder you can use Environment.GetFolderPath or you can get a company\application\version specific subfolder path from Application, My.Application or My.Computer.FileSystem.SpecialDirectories.
 
Somehow I am getting the impression that I have mis-phrased my question or something. I think it will be more proper to phrase my question properly and more accurately. Sorry, if I have gotten you to have the wrong impression. My bad. I have updated the original post with the intended message that I am trying to bring across.

Store an error log file under the Program Data folder. To get the path of that folder you can use Environment.GetFolderPath or you can get a company\application\version specific subfolder path from Application, My.Application or My.Computer.FileSystem.SpecialDirectories.

I suppose you mean this error log file purpose is to log down all the error messages that the user has encountered into this special file right? So that I can grab these error messages for any future debugging right?
 
.Net libraries store all such strings in one or more resource files embedded in each assembly, and access them through a strongly typed ResourceManager proxy (like My.Resouces.). You can add project resources in Resouces page in Project Properies.
 
.Net libraries store all such strings in one or more resource files embedded in each assembly, and access them through a strongly typed ResourceManager proxy (like My.Resouces.). You can add project resources in Resouces page in Project Properies.

Therefore you are suggesting that I placed all the messages that I have made into a text file and have the file stored as a resource?

When my form load, I will have to load the file from the resource and parse the text inside into a hashtable or something right?
 
No, I'm suggesting you have one String value resource for each message. Use them like My.Resources.ErrorLoginInvalid

Here's example from the .Net System.dll: stringresources.png
There's about 1600 more of those messages in that assembly alone.
 
Back
Top