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

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
 
P

Peter Duniho

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
 
R

Roman

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
 

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