liubiao4123 / servicestack

Automatically exported from code.google.com/p/servicestack
0 stars 0 forks source link

TypeInitializationException when deserialiaze a string to a class that have a static property #63

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.
create a simple class that have the a property that return an XElement value 
like this

    public class MyClass
    {
        private string _id;
        public String Id { get { return _id; } set { _id = value; } }

        private string _text;
        public String Text { get { return _text; } set { _text = value; } }

        public static bool IsOk { get; set; }

    }
2.
test the Deserializer in this way

        static void Main(string[] args)
        {
            MyClass req = new MyClass() { Id = "11", Text = "22" };
            string s = req.ToJson();
            MyClass req1 = s.FromJason<MyClass>();
        }

3.

What is the expected output? What do you see instead?
The string deserialized but you get the TypeInitializationException 

What version of the product are you using? On what operating system?
Last ServiceStack.Text Dll on a Windows 7 Pro SP1 with VS 2010 Ultimate and 
.NET 4.0

Please provide any additional information below.

Original issue reported on code.google.com by stiliu...@hotmail.com on 16 Sep 2011 at 8:44