473,396 Members | 2,090 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Serializing CultureInfo problem

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;
}
}

Nov 16 '05 #1
2 6273
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" <ch****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
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;
}
}


Nov 16 '05 #2
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" <ch****@discussions.microsoft.com> wrote in message
news:3F**********************************@microsof t.com...
According to MSDN Library, CultureInfo class is "serializable"
!!(http://msdn.microsoft.com/library/de...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 [C# / .NET MVP]" wrote:
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" <ch****@discussions.microsoft.com> wrote in message
news:1C**********************************@microsof t.com...
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;
}
}



Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Vottero | last post by:
When a class contains a TimeSpan property, XmlSerializer doesn't work. A TimeSpan property is serialized like: <MySpan /> I've read a number of posts that talk about why this happens and how...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
1
by: tommys | last post by:
Hi, I thought that using CultureInfo.CurrentUICulture would give me the current date format as set in the OS - but it did not work that way :-( When re-reading the docs I can see why: "Gets the...
0
by: Maileen | last post by:
Hi, I wrote in VB a small application which save old culture info before to change them for running Excel macro. It looks like that : Dim oldCI As System.Globalization.CultureInfo = _...
1
by: rerdavies | last post by:
OS: WIndows Server 2003. Currently logged in user is running with German(German) regional settings. Code fragment: System.Globalization.CultureInfo culture = new...
8
by: G.Ashok | last post by:
Hi, I have created CultureInfo object and specified required digit grouping in it. The one of the overloaded ToString methods of Decimal type has parameters to format the value with required...
8
by: Phil Jollans | last post by:
Hi, I am having difficulty overriding the ToString() method of CultureInfo using Visual Studio 2005. Exactly the same code works fine with Visual Studio .NET 2003. What I am doing is adding...
2
by: =?Utf-8?B?TmFob20gVGlqbmFt?= | last post by:
Hi, I have a class which has a property of type System.Globalisation.CultureInfo in a class library project based on .NET framework 1.1 (Visual Studio 2003). I want to expose the classes and...
8
by: =?Utf-8?B?T2xpdmllciBHSUw=?= | last post by:
Hello, I try to convert a volume stored as a string value in an XML file into a Decimal object. The volume is stored with comma as decimal separator ("210,12") according to french habits. To be...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.