Visual Studio gives general debug errors, but gives certain errors from debugging

I don't even know what to call it, but here's the situation - I'm using Visual Studio 2013 to create a Windows Forms project. At some point, the debugger started throwing this error:

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: An exception was thrown by the target of the call.

However, I noticed that when I run the program without debugging and an error occurs, it gives me:

System.IndexOutOfRangeException: The index was outside the array.

This is not a complicated program, I am not doing anything yet, like multithreading or delegation. No matter what I try, it only gives the first error. I got this when I was trying to delete a file that didn't exist when the index was out of bounds when the control threw an error. All these errors are just quoted first in debug mode, but normal errors from debug mode.

I just dropped the code into another project and it works great. It might be an option in the debug menu, but I've tried everything I could imagine. I also tried updating to VS2013 Update 4 and it still does it. Help?

+3


source to share


1 answer


An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll

Additional information: Exception has been thrown by the target of an invocation.

      

A TargetInvocationException is a wrapper around the actual exception.
  "The client application event handler delegator must check the Error property, otherwise the property will throw a TargetInvocationException."

Try to return trying to catch and get ex.InnerException and see why it is giving this error

System.IndexOutOfRangeException: Index was outside the bounds of the array.

      



try this also

try {
   //here you read the arguments and pass to a variable
}
catch(System.IndexOutOfRangeException) {
     //other codepart
}

      

Hope it helps

0


source







All Articles