c# - IndexOutOfRangeException: Get Array's Name -
I recently inherited the C # (.NET 4.0) project. This line of project 400k + code and very large, older Uses / catch that block access to the any never catch the exception, but an index Outofarenz throws an exception, and my boss has asked me to try an easy way to highlight the name of Array who threw the exception. (Such big try / catch block can have multiple arrays.) I know that I can use when IndexOutOfRangeException throw is to trigger the code to execute FirstChanceException event. For example:
class ExceptionTest {public static void main () {AppDomain.CurrentDomain.FirstChanceException + = new eventhandler & LT; FirstChanceExceptionEventArgs & gt; (CurrentDomain_FirstChanceException); Int [] arr = new int [0]; Advent [0] = 0; Console.Read (); } Static void CurrentDomain_FirstChanceException (object sender, FirstChanceExceptionEventArgs e) {if (e.Exception.GetType () == typeof (IndexOutOfRangeException)) {Console.WriteLine (e.Exception.StackTrace); }}}
Unfortunately, I can not seem to comb this way through the lines of the 400K + code, to find the name of the problem generating array like this .
I personally do not understand the point of this work, but I appreciate any help. It is also possible
Edit: August 5, 2014
I should clarify: This debugging versus when to find arrays problematic is very easy The issue of this task is that it can be detected which array is being used by our customers to make the program release is throwing an exception. The program uses a set of log files But these files The only exception is that the type of exception is thrown - No array name or line number
use this code
try {// large number of arrays in you int [] arr1; Int [] arr2; // these types of code and announcements} catch (Exception e) {Console.WriteLine (e.Message + "+ e.StackTrace);}
Now it stacktrace will show you how to line There is an error in your code on the number
Comments
Post a Comment