Solved

Intermittent error "Input string was not in a correct format."

Posted on 2014-12-01
20
513 Views
Last Modified: 2014-12-13
Hi,

We've started getting strange errors from within a radwindow in our application that has been running fine for months.

The code has not changed recently.  The error seems to be produced very intermittently, but happens when a users clicks on a button within the radwindow - I've added logging and try catch blocks within every procedure/function in the page that is loaded in the radwindow. The code for the button click event is never fired when the error is prodced, instead the following error is thrown and logged by global.asax.  Do you have any idea what may be causing this?

Error Caught in Application_Error event
Error in: http://mywebsite.co.uk/filter.aspx?SiteID=325413&t=635530314166978027&altIconPath=&sliderSkin=Outlook&filterbg=&bookieList=&List=&List2=&List3=&rwndrnd=0.46842012647539377
Error Message:Input string was not in a correct format.
Stack Trace:   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.ComponentModel.Int32Converter.FromString(String value, NumberFormatInfo formatInfo)
   at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
Target Site:Void StringToNumber(System.String, System.Globalization.NumberStyles, NumberBuffer ByRef, System.Globalization.NumberFormatInfo, Boolean)

This is extremely intermittent, I've never actually manged to reproduce it myself so I'm relying on user feedback and logs.  So, to recap, it seems that as soon as they click on the button (normal asp button) they see the error and I can see from the logs that the handler code for the button click did not seem to run as it should log an event as soon as they click.

The logs do seem to show that when it happens to one user they can retry several times and it keeps erroring for them, but they will be able to use without error, presumably when they refresh the whole page.

I've tried everything I can think of.  Adding logs everywhere, changing buttons from Telerik RadButtons to regular radbuttons, moving to another web server, upgrading from .net 3.5 to 4.5, still the errors come.

Let me know if you need any more information.

Many thanks in advance

cp
0
Comment
Question by:cp30
  • 11
  • 7
  • 2
20 Comments
 
LVL 11

Expert Comment

by:melmers
ID: 40473567
Hello,

such a error is very hard to track. At first you must identify when the error will be thrown.

Can an user reproduce the error for you? Can he create a video or with PSR a file to reproduce the
error correctly? Often error entries written by mail or transfered by phone will have not all details.

Do you have analyzed if the error will only throws by a specific version of browser? (only IE/Firefox/ etc..)

Does this error come if a user inputs the wrong number format like the dot from decimal numbers. In Germany the comma will be used as a decimal point.

Do you have the chance to use IntelliTrace on the server, this requires Visual Studio Ultimate Edition ?

Have you or your admins installed any updates ?

Do you use autmomatic binding of data to your controls ? can the controls update the datasource ?

Regards,

Mario
0
 

Author Comment

by:cp30
ID: 40474159
Hi,

No user can reproduce the error consistently.  I have tracked IPs that have received the error, most are Chrome 39.0 but I have seen one recently which was Opera also.  IPs also show from Uk and other countries.

The only input fields on the form are telerik numeric textboxes and it is impossible for me when testing to enter anything other than the accepted number format.  

We do not have Ultimate Edition of VS :(

No updates have been installed recently.  It is only myself that administers system.

There is automatic binding on some controls on that page, but they do not update the db.

Thanks

Cp
0
 

Author Comment

by:cp30
ID: 40474542
What I cannot understand is how the error can be thrown on the click of a button, yet the code behind that button is never fired (as I have a log event as the first line), but instead the error is thrown.  I've never come across anything like that before, always been able to debug or use logging to find the problem and then resolve.

So even if my textboxes on that page did have string instead of numeric values, surely I'd expect to see that cause an error when the actual code inside the button was run?

Really at a loss with this, never been so stumped and wasted so much time trying to get to the bottom of a .net issue before.
0
 
LVL 11

Expert Comment

by:melmers
ID: 40474835
I assume that you use asp.net webforms. So there are many events before you button handler code will be fired. Have you any code in Page init or page load? There are other events which could run before your button code runs. I will post you tomorrow a link to a page where the rank of the events are shown
.
0
 

Author Comment

by:cp30
ID: 40474847
Hi,

Yes, it is asp.net web forms.  

I have wrapped every sub/function in try catch with logs so I can see when they are started and when they hit an exception.  Problem is, that no code in 'any' procedure of function seems to get fired before the error.

Thanks for posts.

Cp
0
 
LVL 8

Expert Comment

by:Ashutosh Vyas
ID: 40475306
Can you put up the code for your page here. Esp if you have something on Page Init or Page Load.

Even it could be possible that the telerik controls that you are using internally would call some methods to restrict your entries to numeric or convert the entered text to numeric. Thereby raising the errors.

An exact idea of what the controls are and what the page code is would help
0
 

Author Comment

by:cp30
ID: 40475457
Hi,

We only have code in the page load, the other page events are empty (init, preinit etc).  I can copy the code in here if you think that will help but the first thing it does in the page load event is to write to the log and I can see from the logs that that first line never gets run.

I beginning to think it may be worth replacing the RadNumericTextBoxes and validating them as numbers server side or in basic javascript and running that for a while to see if it could be the Telerik RadNumericTextBoxes that are causing the error?
0
 
LVL 8

Expert Comment

by:Ashutosh Vyas
ID: 40475492
This might be a problem with the underlying RadNumeric textboxes.

You could use HTML5 type=number also

<input type="number" min="5" max="18" step="0.5" value="9" >

Open in new window

0
 
LVL 11

Expert Comment

by:melmers
ID: 40475544
Do you bind the property to the text or the value property of the control?
0
 

Author Comment

by:cp30
ID: 40475575
Hi,

I can now rule out the RadNumericTextboxes as I have replaced with standard textboxes and the error still gets logged.  I actually left the textboxes open to non-numeric characters being entered as the code seems to handle this just fine when I test and simply returns a nicely handled error in the grid that gets refreshed  in the underlying page, so I know that it can handle non-numeric values just fine.

Melmers: we were setting the dbValue property of the textbox that Telerik recommend as I believe it handles exceptions better.

We are running out of things to remove from the filter page - I have now removed the 3 Telerik RadListboxes that were also on the page and had to add a message to our users that only limited filtering will be available for a short maintenance period.  We now have only 5 regular textboxes, and a Telerik RadSlider,  I guess it's trial and error to see which controls we remove stops the errors cropping up in the log - as I can't seem to apply much other logic to it.

Many thanks for suggestions so far - any more gladly welcomed.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 11

Accepted Solution

by:
melmers earned 500 total points
ID: 40475581
Do you use master pages as well? If yes do you have logging enabled on the master page?
0
 
LVL 11

Expert Comment

by:melmers
ID: 40475587
Another thing which you can prove, do you use an ORM framework like Entity Framework ?
If yes are the datatypes of your ORM model and the database tables in sync ?
0
 

Author Comment

by:cp30
ID: 40475593
No, sorry, we don't use an ORM framework
0
 
LVL 11

Assisted Solution

by:melmers
melmers earned 500 total points
ID: 40475597
Can you post the code how you retrive the data for the control and the
binding code of the control?
0
 

Author Comment

by:cp30
ID: 40475598
yes, which control - all of them on the page?
0
 
LVL 11

Expert Comment

by:melmers
ID: 40475617
Post the complete code of the page and the master page
0
 

Author Comment

by:cp30
ID: 40475620
Ok, I just need to get confirmation from the company owner to ensure that he's happy for me to share all the code from those pages without removing anything sensitive.

Thanks
0
 

Assisted Solution

by:cp30
cp30 earned 0 total points
ID: 40475674
"think" I may have just found the problem!

Found this post so suspecting that it could well be the listboxes that were causing the issue.  Will regress to previous full-featured page and then apply the fix and wait to see if the problem is resolved

http://www.telerik.com/forums/system-formatexception-78e82e51af27

Fingers crossed!

Thanks

Cp
0
 

Author Comment

by:cp30
ID: 40486658
The link in my last message was indeed my issue exactly and was fixed by the suggested code.

Many thanks for your efforts of assistance.

Cp
0
 

Author Closing Comment

by:cp30
ID: 40497770
Discovered solution and fix from Telerik website.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now