开发者

I want to Deserialize stream as contact in windows phone 7 c#

开发者 https://www.devze.com 2023-04-10 12:22 出处:网络
I Serialized Contact and Saved it in text file in The Isolated Store I want to Deserialize it back as Contact

I Serialized Contact and Saved it in text file in The Isolated Store

I want to Deserialize it back as Contact

I tried this Code but I get error :

Error 1 The type 'Microsoft.Phone.UserData.Contact' has no constructors

using (var reader = new StreamReader(stream))
                {
                    var serializer = new XmlSerializer(typeof(Contact));
                    return reader.EndOfStream
                          ? new Contact()// error
                         : (Contact)serializer.Deserialize(reader);
                }

is there another solut开发者_运维百科ion to get it back ?


That looks like it is not intended for this purpose; all the properties are get, and there is no (public) constructor. XmlSerializer will not work on that.

IMO your best option is to create something of your own that looks like that class, but is serialization-friendly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号