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() 
try..catchand you will get exception on exact line of error