码迷,mamicode.com
首页 > 其他好文 > 详细

序列化文件错误

时间:2015-02-12 13:53:07      阅读:283      评论:0      收藏:0      [点我收藏+]

标签:

问题:当序列化XML文件时,出现错误
用如下方法:
XmlSerializer lizer = new XmlSerializer(typeof(MyType));

  错误如:

The assembly with display name ‘mscorlib.XmlSerializers‘ failed to load in the ‘LoadFrom‘ binding context of the AppDomain with ID 1. The cause of the failure was: System.IO.FileNotFoundException: Could not load file or assembly ‘mscorlib.XmlSerializers, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089‘ or one of its dependencies. The system cannot find the file specified.

 改变方法如下:

XmlSerializer lizer = XmlSerializer.FromTypes(new[] { typeof(MyType) })[0];

  则问题解决

序列化文件错误

标签:

原文地址:http://www.cnblogs.com/luke-lu/p/4287730.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!