When tossing custom exceptions or giving messages towards the consumer, you could use hard-coded the strings (including string constants), use resource-only devices or get strings from the table inside a database.

I'd like my application to have the ability to switch to another language easily without needing to recompile. While storing the string assets inside a set up or database would accomplish this purpose, it increases the complexity of program logic which increases the price of the merchandise.

My real question is: what's the easiest method to go with the aim in your mind without disregarding the price that accompany each option? For those who have an exercise that's much better than what's been listed, I'd like to listen to it.

Technologies: OS: Home windows family Platform: .Internet Frame 2 or more Language: C# Database: MS SQL 2005 or more

Thanks men!

Cullen

Use assets:

So how exactly does this increase the complexity towards the program logic?

try
{
   //do something with System.Net.Mail with invalid email..
}
catch (FormatException fex)
{
    throw new Exception(Resources.ErrorMsg.Invalid_Email, fex);
}

Edit

In VS2008 whenever you produce a resource, you are able to define if it is internal or public. So assume we place it to public, within an set up known as ClassLibrary1, we are able to access a house like:

ClassLibrary1.Qualities.Assets.InvalidError

Where InvalidError may be the title from the error. Again I do not think this adds any compelxity towards the logic.

.Internet already supports multiple assets for multiple cultures utilizing a naming convention:

 <default resource file name>.<culture>.resx

Basically as Josh stated VS2008 produces a pleasant type safe wrapper to gain access to these assets.

Nevertheless the Versus UI exposes the bear the least you skill.

Should you produce a new Resource File known as exactly like the default, however add the culture info prior to the resx. (NOTE: You will have to create it elsewhere then copy it in to the miracle Qualities folder.)

Your application will for those who have applied the culture towards the thread being able to access the resource pull the right string in the specific assets.

For instance:

    // Using the default culture
    string s = Resources.Error1Msg;

    Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-CO");

    // Using the specific culture specified as above:
    s = Resources.Error1Msg;

If you want to parameterize you message, use string.Format to parameterize the output.

Keep your eyes peeled is attempt to architect the application layers in a way that the exceptions have a wealthy payload (to explain the mistake), rather than depending on just text.

This way your presentation layer can present the very best UI experience that might make use of the payload.

HTH

Philip