0

I am executing a c# script (inside SSIS, an ETL tool) in a modified visual studio 2008 (actually called BIDS). I get an error, but the error message does not let me trace the line that caused the error. How do I find out which line is causing the problem.

I tried using, try catch and my SSIS package ran without errors. But, when I remove the try catch, the package execution shows an error. Anyway, all this talk about SSIS is not really needed. Its the error/exception catching which matters here.

 try { //my code here } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } 

The error info is given below -

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_LongCodeNameHere.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() 
14
  • Are you in debug mode? Commented Oct 24, 2013 at 6:45
  • Is there no way to step through the code line-per-line? Commented Oct 24, 2013 at 6:46
  • if u are in debug mode in VS u can enable all exceptions under the menu Debug. Commented Oct 24, 2013 at 6:48
  • 2
    remove try..catch and you will get exception on exact line of error Commented Oct 24, 2013 at 6:50
  • 1
    trust me its much easier in c# Commented Oct 24, 2013 at 6:50

2 Answers 2

2

Have a look at the page "Coding and Debugging the Script Component" on Technet.

In particular, the section "Debugging the Script Component" might give you some pointers:

The Script component does not support the use of breakpoints. Therefore, you cannot step through your code and examine values as the package runs. You can monitor the execution of the Script component by using the following methods:

  • Interrupt execution and display a modal message by using the MessageBox.Show method in the System.Windows.Forms namespace. (Remove this code after you complete the debugging process.)
  • Raise events for informational messages, warnings, and errors. The FireInformation, FireWarning, and FireError methods display the event description in the Visual Studio Output window. However, the
    FireProgress method, the Console.Write method, and Console.WriteLine
    method do not display any information in the Output window. Messages
    from the FireProgress event appear on the Progress tab of SSIS
    Designer. For more information, see Raising Events in the Script
    Component.
  • Log events or user-defined messages to enabled logging providers. For more information, see Logging in the Script Component.

If you just want to examine the output of a Script component configured as a source or as a transformation, without saving the data to a destination, you can stop the data flow with a Row Count Transformation and attach a data viewer to the output of the Script component. For information about data viewers, see Debugging Data Flow.

Sign up to request clarification or add additional context in comments.

Comments

1

Find the image

Chcek all boxes and try to run the code.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.