有没有办法重命名类型化的DataSet,但仍允许它使用以前的名称/架构设置反序列化序列化的数据?
示例:
将原始序列化DataSet以ASP.NET会话状态存储在名为DSAdmin
的数据库中,在将其重命名为AdminDataSet
并再次登录之后将抛出异常,因为它无法反序列化为存储在会话DB中的旧类型的新类型:
[SerializationException: Unable to load type DAL.DataSets.DSAdmin required for deserialization.]
System.Runtime.Serialization.ObjectManager.DoFixups() +14219464
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +244
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +447
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage) +28
System.Web.Util.AltSerialization.ReadValueFromStream(BinaryReader reader) +1224
System.Web.SessionState.SessionStateItemCollection.ReadValueFromStreamWithAssert() +108
System.Web.SessionState.SessionStateItemCollection.DeserializeItem(String name, Boolean check) +338
System.Web.SessionState.SessionStateItemCollection.get_Item(String name) +27
MasterPage.OnInit(EventArgs e) in x:\iis\wwwroot\Admin\MasterPage.master.cs:60
System.Web.UI.Control.InitRecursive(Control namingContainer) +186
System.Web.UI.Control.InitRecursive(Control namingContainer) +291
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2098
更新
数据集的SchemaSerializationMode属性设置为IncludeSchema
。