Serializing CultureInfo problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,
I cannot serialize CultureInfo property as below.
It invokes InvalidOperationException.

[Serializable]
public class One
{
private CultureInfo culture;

[XmlAttribute("Culture")]
public CultureInfo Culture {get {return culture;}}

public One() {}
public One(CultureInfo culture)
{
this.culture = culture;
}
}
 
Hi,

CultureInfo might be not serializable. If you use standard cultures only,
you can just serialize the culture name.
 
Ok, what's the error message in the InvalidOperationException thrown?

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

choyk1 said:
According to MSDN Library, CultureInfo class is "serializable"
!!(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/ht
ml/frlrfsystemglobalizationcultureinfoclasstopic.asp)

[Visual Basic]
<Serializable>
Public Class CultureInfo
Implements ICloneable, IFormatProvider
[C#]
[Serializable]
public class CultureInfo : ICloneable, IFormatProvider
[C++]
[Serializable]
public __gc class CultureInfo : public ICloneable, IFormatProvider
[JScript]
public
Serializable
class CultureInfo implements ICloneable, IFormatProvider


Dmitriy Lapshin said:
Hi,

CultureInfo might be not serializable. If you use standard cultures only,
you can just serialize the culture name.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

choyk1 said:
Hi all,
I cannot serialize CultureInfo property as below.
It invokes InvalidOperationException.

[Serializable]
public class One
{
private CultureInfo culture;

[XmlAttribute("Culture")]
public CultureInfo Culture {get {return culture;}}

public One() {}
public One(CultureInfo culture)
{
this.culture = culture;
}
}
 
Back
Top