Strange Divide? Error

G

Guest

Have we got a STRANGE one going here.

We converted from 1.1 to 2.0 about 2 weeks ago and this has been a problem
since then...but only on SOME machines in our development group. The
application runs fine using 1.1 and on 3 of the 8 machines in our group. It
is a Windows application.

Our appliation has many user controls, and panels/viewing areas that we show
in our app. In our application we several areas where we have to take a
string and parse it into other data types; for
instance--ushort.parse(strSysID). On the problem machines this generates the
following build error:

A first chance exception of type 'System.FormatException' occurred in
mscorlib.dll
TestPointSpec: Error TP 774 not a number 0 System.FormatException: Input
string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseUInt32(String value, NumberStyles options,
NumberFormatInfo numfmt)
at System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo info)
at System.UInt16.Parse(String s)
at ConfigurationFiles.TestPointSpecificationFile.ParseEnumeration(UInt16
specID, String wholeEnum) in D:\C-5 RERP\PVCS
7-26-06\Common\ConfigurationFiles\TestPointSpecificationFile.cs:line 357

In other parts of the application, we may be using the string in a different
way(ie. we use the string/convert it to an int and use it as an index), and
it gets past the build process, but at run time generates the following
error, when trying to use a "0" in a string:

System.FormatException was unhandled
Message="Input string was not in a correct format."
Source="mscorlib"
StackTrace:
at System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
at System.Number.ParseUInt32(String value, NumberStyles options,
NumberFormatInfo numfmt)
at System.UInt16.Parse(String s, NumberStyles style, NumberFormatInfo
info)
at System.UInt16.Parse(String s)
at ApplicationFrame.SubsystemBrowserControl.GetSelectedRows(DataGrid
dg) in D:\C-5 RERP\PVCS
7-26-06\PCIU_CSCI\UserInterfaceComponents\SubsystemBrowserControl.cs:line 1290
at
ApplicationFrame.SubsystemBrowserControl.addTPmenuItem_Click(Object sender,
EventArgs e) in D:\C-5 RERP\PVCS
7-26-06\PCIU_CSCI\UserInterfaceComponents\SubsystemBrowserControl.cs:line 1052

We know it has something to do with having a "0" in a string, but have NO
idea, of why it happens on only some of the machines and not all (luckily I'm
not one of the problem machines), and also why it works with 1.1 version of
the framework, and not 2.0.

Anyone have any ideas of what the problem is, or where we start looking?

My apologies for the length of the post. Thanks in advance for any help.

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
 
B

Barry Kelly

WhiteWizard said:
Have we got a STRANGE one going here.

I have difficulty understanding what your problem is. You're calling
ushort.Parse() with a string, and it isn't a valid string, right? So
panels / viewing areas and related discussion etc. is irrelevant, right?

What exactly is the problem?
at System.UInt16.Parse(String s)
at ApplicationFrame.SubsystemBrowserControl.GetSelectedRows(DataGrid
dg) in D:\C-5 RERP\PVCS

The code that's calling Parse is under your control - surely you can
isolate the value that's being passed to ushort.Parse()?

-- Barry
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

You have some error in the format of the number, can you post the code in
question?
Also compare one working machine and one with the error regarding the
culture being used , especifucally the NumberFormatInfo benig used.
 
G

Guest

Ok, so I obviously didn't get the message out ;) I HATE it when that happens!

The problem is that WHENEVER we have a string with a value of "0", we have a
problem. The errors we just examples of some of the problems. And it
appears that it ONLY happens when the value of the string is "0".

We did check the versions of the framework we are using, but have NOT
checked the NumberFormatInfo as suggested, so I'll do that today.

Thanks for the responses!

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
 
G

Guest

I have good news and bad news.

The good news is that with Ignacio's suggestion we checked the
NumberFormatInfo parameters and found that for the problem machines the
PositiveSign Value is a 0, but only for en-US and only on the problem
machines.

I also verified that this is what was causing the problem by temporarily
changing my value to a 0 and got the errors.

The bad news is I cannot find any way to change the value back to a + sign
as it is on the non-problem machines and for all other culture settings. I
also have no idea HOW the bad ones were set to 0 in the first place.

I found where you can change how the system treats negative numbers, but
nothing so far on setting the PositiveSign value. Has anyone seen this
before, or can anyone tell me how I might change the PositiveSign value?

Thanks for your responses earlier. It definitely helped us isolate the
problem.

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


One of the Parse variants takes a NumberFormatInfo you can use it. The weird
thing is that you say that you get error not when you have a '+' in front
but when you have a 0 , so +1 is ok, , but 01 which is kind of weird.

why don't you try with this version and use InvariantCulture as the
parameter.
 
C

Claes Bergefall

You should be able to change them in the registry at
HKEY_CURRENT_USER\Control Panel\International
or
HKEY_USERS\.DEFAULT\Control Panel\International

The value your looking for is sPositiveSign. It is set to an empty string on
my machine

/claes
 
G

Guest

Thanks for the response, but I checked the problem machine, and both of those
registry entries show an empty string.

While I love puzzles like this as much as the next guy, this is getting
REALLY ridiculous! ;)

WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
 
M

mike

did you ever solve this issue?
I am have the same problem. Can not insert a 0 (zero) into the datagridview.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top