Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Thursday, 6 June 2013

Input string was not in a correct format exception thrown by DevExpress controls

Recently I have stumped upon an exception thrown by DevExpress controls and this is trace :
2013-06-04 15:29:37.9138   6: csdrtg55bpufcimx3dm2o145 Error:global_asax threw EXCEPTION: Input string was not in a correct format.
2013-06-04 15:29:37.9138   6: csdrtg55bpufcimx3dm2o145    SOURCE:mscorlib 
2013-06-04 15:29:37.9138   6: csdrtg55bpufcimx3dm2o145    METHOD:StringToNumber 
2013-06-04 15:29:37.9138   6: csdrtg55bpufcimx3dm2o145    STACK is as follows:
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Int32.Parse(String s)
   at DevExpress.Web.ASPxEditors.ListEditItemsSerializingHelper.ParseItemIndex(String serializedItem, Int32& startPos)
   at DevExpress.Web.ASPxEditors.ListBoxItemsSerializingHelper.DeserializeItems(String serializedItems, Boolean sortRequired)
   at DevExpress.Web.ASPxEditors.ListBoxProperties.SynchronizeItems(String serializedItems, Boolean isInsertingSyncType)
   at DevExpress.Web.ASPxEditors.ASPxComboBox.SynchronizeItems(NameValueCollection postCollection)
   at DevExpress.Web.ASPxEditors.ASPxComboBox.LoadPostData(NameValueCollection postCollection)
   at DevExpress.Web.ASPxClasses.ASPxWebControl.LoadPostDataInternal(NameValueCollection postCollection, Boolean raisePostDataEvent) 
2013-06-04 15:29:39.7810   6: csdrtg55bpufcimx3dm2o145 Callback error message : Input string was not in a correct format. 

Everything works fine If I debug the code and I am not able to see any exception been thrown. So made so many changes to code to see cause of failure but finally gave up. Then realised that visual studio allows you to catch CLR exceptions and here are the steps I have taken to find out the culprit :
1. First disable "Just My Code".
Tools -> Options

2. Enable CLR exceptions
Debug -> Exceptions

3. Now start debugging the code and skip all exceptions until you reach the exception that you are looking for.

4. After seeing the exception that you are looking for, use "Ok" button not "Continue" button.

5. Now see call stack window

6. You will have enable "Parameter Names" to see the control name that has caused the issue

Now your callstack should show something like this

Callstack will show you the control name and its data that has caused the failure.

Man is the best computer we can put aboard a spacecraft... and the only one that can be mass produced with unskilled labor. ~Werner von Braun


Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers