I have the following code in a script task but when I try execute the script I get an error with the following message: "Exception has been thrown by the target of an invocation. ---> Object reference not set to an instance of an object."
I am trying to address a deadlock error in my package with the use of variables. Based on the value of Region, I'm trying to populate another variable InputRegion.
public void Main()
{
String InputFile;
int StrLen;
Variables var = null;
Dts.VariableDispenser.LockOneForWrite("User::Region", ref var);
var[0].Value = "DEFAULT";
InputFile = (String)vars["User::InputRegion"].Value;
if (InputFile == "Europe.txt")
var[0].Value = "European";
if (InputFile == "Amers.txt")
var[0].Value = "American";
if (InputFile == "Tokyo.txt")
var[0].Value = "Asian";
else
var[0].Value = "Unknown";
var.Unlock();
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}