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.
精彩评论