Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
hi,
 
namespace trycatchtest
{
    class Program
    {
        static void Main(string[] args)
        {
            tryTest t = new tryTest(1);
        }
    }
 
    public class tryTest
    {
 
        public tryTest(int a)
        {
            try
            {
 
                string filePath = @"D:\FTP Root\BUS_01_Argese\CDR\Template1\1Row.csv";
                var orders = System.IO.File.ReadAllLines(filePath).Skip(1);
                var query = from line in orders.AsParallel()
                            select new
                            {
                                CallingNumber = GetCDRColumn()
                            };
 

 

                var col = query.ToList();
 
            }
            catch (Exception ex)
            {
                string s = ex.Message;
            }
        }
 
        private string GetCDRColumn()
        {
            try
            {
                throw new Exception("My error");
 
                return string.Empty;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 
    }
}
 
this is my code i handled error using try catch but when running this program also showing error was unhadled by used code but this happen only i read from file.
Posted 7-Jul-11 1:07am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

I can't obviously see where an exception could get through your handlers, but i bnotice that some of your code is not there anyway - otherwise it wouldn't compile (CallingNumber is not declared). It may be other code which is throwing the exception.
 
In VS, on the menu bar, select "Debug...Exceptions"
In the dialog that appears, make sure there is a tick in every box under both "Thrown" and "User-unhandled".
Press OK.
Now when your program throws an exception, the debugger will break on the line that causes it, whether you have a handler or not. You should be able to work out where the problem is from there.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,466
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,897


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 7 Jul 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100