Home » SQL ServerRSS

"Dts.VariableDispenser.GetVariables" function hangs when "Dts.VariableDispenser.LockForWrite" is use

I am executing a script task in an OnError EventHandler under SSIS 2008. The code hangs on this line


      Dts.VariableDispenser.GetVariables(ref variables);

when I add the following lines

      Dts.VariableDispenser.LockForWrite("User::varErrorTypeId");
      Dts.VariableDispenser.LockForWrite("User::varErrorDescription");


and it doesn't hang when those two lines are commented. Body of code reproduced below for you information. Can you please help me?


Variables variables = null;
try
{
	Dts.VariableDispenser.LockForRead("System::ErrorDescription");

	Dts.VariableDispenser.LockForWrite("User::varErrorTypeId");
	Dts.VariableDispenser.LockForWrite("User::varErrorDescription");
        
    Dts.VariableDispenser.GetVariables(ref variables);

	Dts.Variables["User::varErrorTypeId"].Value = 1;
    Dts.Variables["User::varErrorDescription"].Value = Dts.Variables["System::ErrorDescription"].Value;
}
catch (Exception)
{
	throw;
}
finally
{
	variables.Unlock();
}


TIA,
Barkingdog

 

1 Answer Found

 

Answer 1

Did you setup these variables in the dialog for the ReadOnlyVariables or ReadWriteVariables property? If you are doing it, this would explain why you are not able to lock these variables in the script.
 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter