Experimenting with the CultureInfo class
I found a thread on SSIS and References, in particular culture info using System.Globalization in c# on the internet...said that it didn't work with SSIS. And at this point, I agree. I've been dorking with this thing yesterday afternoon and this morning and can't get the thing to use a resource other than the default. Works fine in a simple console app like below. Create your resource files accordingly, add values to them , compile the following, and you're gold.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ReferencePOC
{
public class Program
{
static public int x;
static void Main(string[] args)
{
bool val = false;
if (val)
loc();
else
fr();
}
static public void loc()
{
System.Globalization.CultureInfo ciDefault = System.Globalization.CultureInfo
.InstalledUICulture;
System.Threading.Thread.CurrentThread.CurrentCulture = ciDefault;
string lbl = ReferencePOC.Properties.Resources.String1.ToString();
Console.WriteLine(lbl.ToString());
}
static public void fr()
{
System.Globalization.CultureInfo ciMX = new System.Globalization
.CultureInfo("es-MX");
System.Threading.Thread.CurrentThread.CurrentUICulture = ciMX;
string lblX = ReferencePOC.Resources_es_MX.String1;
Console.WriteLine(lblX.ToString());
}
}
}
Why would you want to do this in SSIS? Well, one example would be to maybe change culture info or language in an email depending on certain factors. For instance, in SSIS if an error occurs in the middle of the night, the language might be changed in the email text for the team handling first-level support at that time.
There are a couple of problems that I see here. First, the Resources.es-MX.resx file will be created but will not have any code for the ResourceManager; I copied/pasted mine from the console app. That worked initially but sometimes this code gets "lost", and I had to go back and paste it and recompile. Second, it seems that SSIS is caching the initial value that you place in the default .resx file, because if I change the value it returns the value to a message box. (I did this because I noticed that when I tried to invoke the es-MX string from the resource file I got the default, so I changed the default string value, but ended up getting the old value again! Searching the files in the solution, I couldn't find the old value anywhere stuck in the metadata. WTH?).
Here's what I put in SSIS. Notice that it's nearly the same code as the console application:
private static void Default()
{
System.Globalization.CultureInfo ciDefault = System.Globalization.CultureInfo
.InstalledUICulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = ciDefault;
string lbl = SC_ecc2cd9fb8de4539bc595a5cd92b45fc.csproj.Properties
.Resources.String1;
System.Windows.Forms.MessageBox.Show(lbl.ToString());
}
private static void ci_MX()
{
System.Windows.Forms.MessageBox.Show("in MX");
System.Globalization.CultureInfo ciMX = new System.Globalization
.CultureInfo ("es-MX");
System.Threading.Thread.CurrentThread.CurrentUICulture = ciMX;
string lblX = referencepoc.Resources_es_MX.String1;
System.Windows.Forms.MessageBox.Show(lblX.ToString());
}
This is worth experimenting with more because I see some value here. It might be that I'll need to create a custom assembly to get it to work, separating the logic out from underneath the control of the SSIS project. I'll try that next, but will save it for another day.
Lee
------------------------------
Fail! Ugh.

db60a4cd-8367-4151-8449-4a04196d610a|0|.0