hello my friends
during serializing my from I recive an exception that
I write it

System.InvalidOperationException: There was an error reflecting type 'xml_serialization.Form1'. ---> System.NotSupportedException: Cannot serialize member System.ComponentModel.Component.Site of type System.ComponentModel.ISite because it is an interface.
   at System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, Boolean canBePrimitive, MemberInfo memberInfo)
   at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference)
   at System.Xml.Serialization.StructModel.GetPropertyModel(PropertyInfo propertyInfo)
   at System.Xml.Serialization.StructModel.GetFieldModel(MemberInfo memberInfo)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
   at System.Xml.Serialization.XmlReflectionImporter.ImportStructLikeMapping(StructModel model, String ns)
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(TypeModel model, String ns, ImportContext context, String dataType, Boolean repeats)
   at System.Xml.Serialization.XmlReflectionImporter.ImportElement(TypeModel model, XmlRootAttribute root, String defaultNamespace)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
   at System.Xml.Serialization.XmlSerializer..ctor(Type type)
   at xml_serialization.Form1.menuItem4_Click(Object sender, EventArgs e) in d:\documents and settings\ma
and my codes were

public void mouse_up(object sender,MouseEventArgs e)
  {
   try
   {
    if(e.Button==MouseButtons.Right)
     contextMenu1.Show((Control)sender,new Point(e.X,e.Y));
   }
   catch
   {
    ;
   }
  }
  private void menuItem2_Click(object sender, System.EventArgs e)
  {
   propertyGrid1.SelectedObject=contextMenu1.SourceControl;
  }
  private void menuItem4_Click(object sender, System.EventArgs e)
  {
   try
   {
    SaveFileDialog fd=new SaveFileDialog();
    fd.Filter="(*.xml)|(*.*)";
    fd.ShowDialog();
    //fd.AddExtension=true;
    if(fd.CheckPathExists)
    {
  
    
     // Insert code to set properties and fields of the object.
     XmlSerializer mySerializer = new
      XmlSerializer(contextMenu1.SourceControl.GetType());
     // To write to a file, create a StreamWriter object.
     StreamWriter myWriter = new StreamWriter(fd.FileName);
     mySerializer.Serialize(myWriter,contextMenu1.SourceControl);
    }
   }
   catch(Exception ex)
   {
    MessageBox.Show("please repeat"+ex.ToString());
    StreamWriter str=new StreamWriter("c:\\er.txt");
    str.WriteLine(ex.ToString());
   }
  }
can any one help me
thank you



Start your day with Yahoo! - make it your home page

SPONSORED LINKS
Programming languages C programming language Computer programming languages
Java programming language C programming language History of computer programming language


YAHOO! GROUPS LINKS




Reply via email to