0

I am trying to build a package with a Script Task and load parameter values to local variables.

I created Project and package Parameters. enter image description here

and called them into the script task editor In the script Editor I entered the following script enter image description here Build show success! Executing the package I get a RunTime error

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

And That unfortunately I don't understand the Message. Need help!

Thanks Dov

dovk179
  • 13
  • 1
  • 7
  • Script messages are useless. Use the method I mentioned here to insert code to show a useful error message (assuming you are runnning this interactively) http://stackoverflow.com/questions/33643521/sql-server-2012-ssis-script-task-for-sending-mail-from-gamil-to-gmail-showing?noredirect=1#comment55139112_33643521. Also in line with this debugging approach comment out each line individually until you find the line throwing the error. It helps narrow down the cause. – Nick.Mc Nov 13 '15 at 00:23
  • 1
    So at the end of your script put `catch (Exception ex) { MessageBox.Show(ex.Message.ToString()); }` – Nick.Mc Nov 13 '15 at 00:23

1 Answers1

0

I was able to reproduce the error you posted above, it appears that the problem is with the casing of the variables in your script.

First of all you will need to make sure you have set the variables as either Readonly or ReadWrite, you can do this on the properties of the script task

enter image description here

Then you will need to update your variables:

It should be:

$Project::ServerName instead of $project::ServerName

Notice the difference in case of Project and project - this is what's causing your problem.

enter image description here

kzhen
  • 3,020
  • 19
  • 21