473,386 Members | 1,873 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,386 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 6271
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.