0

I came to ask some advice before I plunge headfirst into code.

On the application I am working on, I am running into the "," (comma) vs "." (dot) discrepancy for a decimal separator.

When I persist to a file, change the regional settings and reopen said file, I am running into exceptions on deserialization.

My question is as follows.

If I use invariant culture info everywhere where serialization/deserialization happens, will I run into this problem again? In my mind, this should work everywhere, even if regional settings get changed. Am I correct in assuming this ?

Another idea which is not ideal is to associate\persist a current cultureinfo with a saved file. Not very nice to do.

I would welcome any advice and insight into this issue. If anything is unclear, please feel free to comment.

Thanks in advance for all your help!!

Marcel De Villiers
  • 1,682
  • 4
  • 15
  • 17

1 Answers1

2

You should use invariant culture anytime you are persisting to a backend. Culture specific formats should only be presented directly to a user. Data changes between versions of Windows and you will not be protected from exceptions associated with deserialization unless you use standard formats that do not change.

Eric MSFT
  • 3,246
  • 1
  • 18
  • 28