473,624 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Very strange "input string not in correct format" bug

Jen
One user of my application is experiencing an exception "input string not in
correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an Int16
(using Convert.ToInt16 ). How can that be? There are other text boxes that
are used in the identical fashion and they don't generate the exception.
All there are many other machines running my application that don't generate
the exception at all.

I have no idea what the problem could be and am looking for ideas.
Mar 6 '07 #1
13 10375
Jen <no**@nowhere.c omwrote:
One user of my application is experiencing an exception "input string not in
correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an Int16
(using Convert.ToInt16 ). How can that be? There are other text boxes that
are used in the identical fashion and they don't generate the exception.
All there are many other machines running my application that don't generate
the exception at all.

I have no idea what the problem could be and am looking for ideas.
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 6 '07 #2
Jen
I can post the relevant code snippets but I doubt I can reproduce the
problem. It's only occuring on one machine out of about a dozen tested.
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************** *@msnews.micros oft.com...
Jen <no**@nowhere.c omwrote:
>One user of my application is experiencing an exception "input string not
in
correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an
Int16
(using Convert.ToInt16 ). How can that be? There are other text boxes
that
are used in the identical fashion and they don't generate the exception.
All there are many other machines running my application that don't
generate
the exception at all.

I have no idea what the problem could be and am looking for ideas.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 6 '07 #3
Jen <no**@nowhere.c omwrote:
I can post the relevant code snippets but I doubt I can reproduce the
problem. It's only occuring on one machine out of about a dozen tested.
Can you produce a short but complete program that fails on that single
machine? (A console app would be easiest.)

It does sound very odd...

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 6 '07 #4
Jen
I'll see what I can do.

This almost smells like a culture-conversion type of problem. But
converting a string that only contains an integer number (and a small
integer number at that) to an int16? How can that fail? But I've been
Googling and it appears others have experienced it as well. Not sure about
an easy fix yet though.
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************** *@msnews.micros oft.com...
Jen <no**@nowhere.c omwrote:
>I can post the relevant code snippets but I doubt I can reproduce the
problem. It's only occuring on one machine out of about a dozen tested.

Can you produce a short but complete program that fails on that single
machine? (A console app would be easiest.)

It does sound very odd...

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Mar 7 '07 #5
On Mar 6, 2:13 pm, "Jen" <n...@nowhere.c omwrote:
I can post the relevant code snippets but I doubt I can reproduce the
problem. It's only occuring on one machine out of about a dozen tested.
This sounds similar to a problem I saw a few months ago:

"Convert.ToInt3 2("0") throws an exception, some systems"
http://groups.google.com/group/micro...b8e300c7c60821

I filed a bug with Microsoft; they're not able to reproduce it. You
might want to post some details in that bug report:

https://connect.microsoft.com/feedba...1.0&siteid=210

Michael

Mar 7 '07 #6
Jen
Yep, it sounds just like my problem. I'm using .NET 2.0 as well.

<mp*******@gmai l.comwrote in message
news:11******** *************@v 33g2000cwv.goog legroups.com...
On Mar 6, 2:13 pm, "Jen" <n...@nowhere.c omwrote:
>I can post the relevant code snippets but I doubt I can reproduce the
problem. It's only occuring on one machine out of about a dozen tested.

This sounds similar to a problem I saw a few months ago:

"Convert.ToInt3 2("0") throws an exception, some systems"
http://groups.google.com/group/micro...b8e300c7c60821

I filed a bug with Microsoft; they're not able to reproduce it. You
might want to post some details in that bug report:

https://connect.microsoft.com/feedba...1.0&siteid=210

Michael

Mar 7 '07 #7
bob
Hi Jen,
This is based on nothing but intuition and witchcraft.
Can you check the culture info of the thread just prior to the offending
instruction?
regards
Bob

"Jen" <no**@nowhere.c omwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
One user of my application is experiencing an exception "input string not
in
correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an
Int16
(using Convert.ToInt16 ). How can that be? There are other text boxes
that
are used in the identical fashion and they don't generate the exception.
All there are many other machines running my application that don't
generate
the exception at all.

I have no idea what the problem could be and am looking for ideas.


Mar 7 '07 #8
What diffrences have the machines that generate exception?
Framework version, hot fixes, OS fixes, UI language/culture etc.?
I tried to reproduce the exception by setting the thread culture to all
possibile cultures I have (158) but did not get any exception from
Convert.ToInt16 ("172").
The only thing I cannot test that could have something to do with cultures
are the UI cultures but, I'd rather check first what are the differences.
"Jen" <no**@nowhere.c omha scritto nel messaggio
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
One user of my application is experiencing an exception "input string not
in correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an
Int16 (using Convert.ToInt16 ). How can that be? There are other text
boxes that are used in the identical fashion and they don't generate the
exception. All there are many other machines running my application that
don't generate the exception at all.

I have no idea what the problem could be and am looking for ideas.

Mar 7 '07 #9
Jen
I can't really do a detailed analysis of the differences because the
offending machine is not accessible to me at the moment.

What the code is doing is it's taking a string from a TextBox that is part
of a User Control and converting it to a short. The exception's trace looks
something like this:

System.Number.S tringToNumber()
System.Number.P arseInt32()
System.Number.I nt16.Parse()
Util.IPAddressB ox.get_Octet3() <-- this is an Int16 property in my user
control

I'm not sure why the call to ParseInt32 is there but I guess that's the way
it works. I've also seen the exception happen with textboxes that convert
right to Int32 instead of Int16. They are also accessed through a property
of a user control.
I am having the guy that owns the machine try the "set locale to something
else then back again to English (US)" trick that someone mentioned to see if
that fixes it. If it does not I'll pursue additional debugging.
"Laura T." <LT@NOWHERE.COM wrote in message
news:eK******** *****@TK2MSFTNG P06.phx.gbl...
What diffrences have the machines that generate exception?
Framework version, hot fixes, OS fixes, UI language/culture etc.?
I tried to reproduce the exception by setting the thread culture to all
possibile cultures I have (158) but did not get any exception from
Convert.ToInt16 ("172").
The only thing I cannot test that could have something to do with cultures
are the UI cultures but, I'd rather check first what are the differences.
"Jen" <no**@nowhere.c omha scritto nel messaggio
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>One user of my application is experiencing an exception "input string not
in correct format". But it makes no sense where it is occurring. It is
occurring when a string from a textbox ("172") is being convert to an
Int16 (using Convert.ToInt16 ). How can that be? There are other text
boxes that are used in the identical fashion and they don't generate the
exception. All there are many other machines running my application that
don't generate the exception at all.

I have no idea what the problem could be and am looking for ideas.


Mar 7 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3043
by: Punisher | last post by:
Ok I'm trying to reference a specific node in a tree. TreeNode nodeParentChannel = treeview1.Nodes; It bugs out with this error: Input string was not in a correct format Obviously 1.2 is not an int. How can I reference this node?
1
8735
by: The Crow | last post by:
if the reason for error is simple, excuse me. but i cant find what the reason is. Here is the snippet : string script = String.Format(@"<script src='common.js' type='text/javascript'></script> <script language='javascript' type='text/javascript'>
0
25852
by: phmyhn | last post by:
I have two web pages, one is viewlarger.aspx, another one is shoppingcart.aspx. On the viewlarger.aspx, when clicking "add to cart" image button, the sub appends the id (passed from another page from a hyperlink column) into a session. the code is as following: Private Sub ibtAddtoCart_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ibtAddtoCart.Click idStr = Session("ids") pid =...
1
3996
by: John Chorlton | last post by:
I've been attempting to pass a chunk of data back from a child Windows form using public properties on the form and have been getting some odd errors. I wanted to return a row of data to avoid creating many public properties on the form to do the same thing. At first I tried returning a DataViewRow. This worked fine until I reached the phone field on the parent table and the code Child form public DataRowView SelectedAddres ge ...
2
2356
by: chongo | last post by:
Hi, i'm reading in a bigint value from SQL Server. string s = myReader.ToString()); int intBackColour = System.Convert.ToInt32(s); I'm also reading in other values the same way and it works great except this one value, i'm getting
3
11740
by: dan | last post by:
I am using VB.NET 2003 and SQL Server 2000. The program uses ADO.NET . The following instruction: Me.cd_insertDataRecord.ExecuteNonQuery() throws this exception: ">>>ProcessDataRecord/ Exception: Type= System.FormatException Message: Input string was not in a correct format. StackTrace: at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
1
4918
by: James Pose | last post by:
Convert.Int32 fails for "0" but works fine for all other numbers. This does not work on one machine when "0" it works fine on other machines Convert.ToInt32(“0”); gives exception {"Input string was not in a correct format."} If I specify base 10 this works on all machines Convert.ToInt32(“0”,10); So I have 3 related questions.
3
2043
by: Pieter Coucke | last post by:
Hi, When a user types a non numeric-value in a numeric column in a DataGridView, and he tries to leave the cell, he gets this "Input string was not in a correct format."-exception. Is there a (nice) way to get rid of this exception? And just put a "0" in the place? Or somehow trigger this single exception (does exceptions have a unique type-number?) and do some appropriate actions?
9
8180
muaddubby
by: muaddubby | last post by:
Hi I'm running into a scenario with a DataSet that has a schema loaded into it, tries to then load data (that matches the schema), and fails with a "Input string was not in a correct format" exception because the decimal field in one of the incoming fields is written in exponential form. I've looked at generating the XML with a fully written decimal value (as opposed to using exponential notation) but that's an issue because right now the...
0
8240
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6111
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.