Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic problem with serialize (Read 5046 times)
jackhuclan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Nov 17th, 2011
problem with serialize
Jan 6th, 2012 at 9:23am
Print Post  
Diagram.SaveToXml() or SaveToString() twice will raised errors. The diagramNode tag binding an object seems like
Class Sample:INotifyPropertyChanged
{
private string _name;
public string Name
{
get{return _name;}
set
{
_name=value;
OnPropertyChanged("Name");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
if(PropertyChanged!=null)
PropertyChanged(this,new PropertyChangedEventArgs(propertyName);
}
}

when call the diagram save* method ,will report error: Type 'System.ComponentModel.PropertyChangedEventManger ' in Assembly 'WindowsBase.Version=4.0.0.0,cultere=......' is not marked as serializable.

please  help...,thanks
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: problem with serialize
Reply #1 - Jan 6th, 2012 at 11:22am
Print Post  
The classes whose objects you are using as Tag values must be serializable. Mark them with the [Serializable] attribute, and implement the ISerializable interface if some of their fields are not serializable (such as PropertyChangedEventManger you mentioned causing the exception).

Alternatively, handle the SerializeTag event to save the tags as Xml elements; see the SiteMap sample project for an example.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jackhuclan
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Nov 17th, 2011
Re: problem with serialize
Reply #2 - Jan 9th, 2012 at 3:22am
Print Post  
It's very useful ,thanks
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint