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

StackOverflow https://stackoverflow.com/questions/5430190

سؤال

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.cs: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;
    } 

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top