Exception Handling in script task in SSIS ?

  • I get exceptions in my C# script task. Does SSIS point to the exact line which caused it ? If not, then its going to be a real pain to use script task for long complicated code. Any suggestions on how to easily find the source of the problem ?

    Example of the error I am facing now -

    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

    ---> System.NullReferenceException: Object reference not set to an instance of an object.

    at ST_007.csproj.ScriptMain.Main()

    --- End of inner exception stack trace ---

    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

    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()

  • You could set a Breakpoint in your Script taskand step through the code until you encounter the error, possibly.

  • blasto_max (1/8/2014)


    I get exceptions in my C# script task. Does SSIS point to the exact line which caused it ? If not, then its going to be a real pain to use script task for long complicated code. Any suggestions on how to easily find the source of the problem ?

    Example of the error I am facing now -

    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

    ---> System.NullReferenceException: Object reference not set to an instance of an object.

    at ST_007.csproj.ScriptMain.Main()

    --- End of inner exception stack trace ---

    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

    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()

    Seems like you have some NULL issues going on.

    Walk through the script with a debugger and you'll find it in no time.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • I'll try this - http://msdn.microsoft.com/en-us/library/ms140033(v=sql.105).aspx

    How to: Debug a Script by Setting Breakpoints in a Script Task

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply