CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]Index was outside the bounds of the

  • Thread starter Thread starter Roman
  • Start date Start date
R

Roman

Hi,

We use a function to get the current decimal separator from a
WindowsServer:

CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]

This was running fine for many Years. In the last few months something
happend and this function starts to throw exceptions: Index was
outside the bounds of the array

The function is used from a Windows Service running under the local
system account. The regional settings are ok and it is working when I
call as a user (local admin)

What's going wrong here?

Regards
Roman
 
Hi,

We use a function to get the current decimal separator from a
WindowsServer:

CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]

This was running fine for many Years. In the last few months something
happend and this function starts to throw exceptions: Index was
outside the bounds of the array

The function is used from a Windows Service running under the local
system account. The regional settings are ok and it is working when I
call as a user (local admin)

What's going wrong here?

Assuming you are correct about exactly where the error is occurring, it
sounds like you have a culture with a NumberFormat property that has no
elements in the NumberDecimalSeparator collection.

Without a concise-but-complete code example that reliably reproduces the
problem, it would be very difficult to anticipate _why_ that might be. It
could be that things are not as "ok" as you think they are with your
OS/.NET installation.

Pete
 
Hi Pete,

The error occurs exactly at the line:

char Separator =
CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0] ;

Its not possible to set the current culture to non specific culture
(e.g. "en"). If there is a culture without comma separator a 'not
supportet exception' is thrown instead of the Index out of bounds
exception.
Anyway restarting the system helped in this case but there is still
the bad feeling about the occurence of this issue...

Thanks
Roman
 
Back
Top