开发者

When I run the program by stepping in using breakpoints, it executes fine, but when I run it without breakpoints, it gives run time exceptions

开发者 https://www.devze.com 2023-02-20 05:49 出处:网络
I have a WPF application in which I am reading an Excel file using Microsoft Jet Oledb driver. There are a total of three excel files being read and inserted into the database after applying necessary

I have a WPF application in which I am reading an Excel file using Microsoft Jet Oledb driver. There are a total of three excel files being read and inserted into the database after applying necessary type conversions.

When I set breakpoints and debug it step by step, I get not exceptions and data is correctly inserted into the DB.

But when I execute it without breakpoints and do not debug, then it gives me the following run time error:

"Input string was not in a correct format"

Please help me. Why is this happening ?

UPDATE:

Stack Trace is: at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) at System.String.System.IConvertible.ToDouble(IFormatProvider provider) at System.Convert.ToDouble(Object value) at Expedia.MainWindow.InsertCallProfile(DataTable dt) in D:\expedia\Expedia\Expedia\MainWindow.xaml.cs:line 90 at Expedia.MainWindow.Button_Click(Object sender, RoutedEventArgs e) in D:\expedia\Expedia\Expedia\MainWindow.xaml.c开发者_Python百科s:line 44

I knew that there is a Type Conversion problem, but it does not occurr when I set breakpoints and debug.

I am using following for converting data types:-

public static Nullable<T> ToNullable<T>(this object o) where T : struct
    {
        Nullable<T> result = new Nullable<T>();
        try
        {
            if (!string.IsNullOrEmpty(o.ToString()))
            {
                TypeConverter conv = TypeDescriptor.GetConverter(typeof(T));
                result = (T)conv.ConvertFrom(o);
            }
        }
        catch
        {
        }
        return result;
    } 


It is not something strange if you know how to debug .NET crash in this way,

http://blogs.msdn.com/b/tess/archive/2009/03/20/debugging-a-net-crash-with-rules-in-debug-diag.aspx

Every crash can be explained.

0

精彩评论

暂无评论...
验证码 换一张
取 消