Problem mit XML Serialisierung



Hi NG,
ich habe eine Klasse, welche ich serialisieren will, jedoch erhalte ich
jedesmal beim ersten element einen Fehler, Fehler beim Reflektieren des Typs
'XXX'

hier mal der gesamte quellcode:
[XmlRoot("Assignment")]
public sealed partial class Assignment {
private List<AssignmentField> fields = new List<AssignmentField>();
private AssignmentControl control = new AssignmentControl();
private bool valid;

[XmlAttribute("Control")]
public AssignmentControl Control {
get {
return control;
}

set {
control = value;
}
}

[XmlAttribute("Field")]
public List<AssignmentField> Fields {
get {
return fields;
}

set {
fields = value;
}
}

[XmlIgnore()]
public bool isValid {
get {
return valid;
}

private set {
valid = value;
}
}

public Assignment() {
}

/// <summary>
/// default constructor
/// </summary>
public Assignment(string file) {
FileStream filestream = File.Open(file, FileMode.Open);

XmlDocument document = new XmlDocument();
XmlReaderSettings settings = new XmlReaderSettings();
ValidationEventHandler handler = new
ValidationEventHandler(Assignment_ValidationEventHandler);

XmlSchema schema =
XmlSchema.Read(ResourceHelper.SearchResourceStream("Assignment.xsd"),
handler);

settings.Schemas.Add(schema);

//add resolver to pass security if accessing web site to recieve
schema
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials =
System.Net.CredentialCache.DefaultCredentials;
settings.XmlResolver = resolver;
settings.ValidationType = ValidationType.Schema;

//this line is neccessary for validation to work
settings.ValidationEventHandler += new
ValidationEventHandler(Assignment_ValidationEventHandler);
XmlReader reader = XmlReader.Create(filestream, settings);
document.Load(reader);
filestream.Close();
}

public void Serialize() {
//write to XML
}

public void Serialize(string file) {
StreamWriter writer = new StreamWriter(file);

try {
XmlSerializer serializer = new
XmlSerializer(typeof(Assignment));
serializer.Serialize(writer, this);
} catch (Exception ex){
System.Windows.Forms.MessageBox.Show(ex.Message);
} finally {
writer.Close();
}
}

public void Deserialize() {
//load from XML

}

public void Deserialize(string file) {
StreamReader reader = new StreamReader(file);

try {
XmlSerializer serializer = new XmlSerializer(this.GetType());
serializer.Deserialize(reader);
} catch (Exception ex) {
System.Windows.Forms.MessageBox.Show(ex.Message);
} finally {
reader.Close();
}
}

private void Assignment_ValidationEventHandler(object sender,
ValidationEventArgs args) {
//the Assignment is invalid
isValid = false;
}
}

public sealed partial class AssignmentField {
private string guid;
private string david;
private string cobra;

[XmlAttribute("GUID")]
public string GUID {
get {
return guid;
}

set {
guid = value;
}
}

[XmlAttribute("David")]
public string David {
get {
return david;
}

set {
david = value;
}
}

[XmlAttribute("Cobra")]
public string Cobra {
get {
return cobra;
}

set {
cobra = value;
}
}
}

public sealed partial class AssignmentControl {
private int type;
private bool ignore;
private string name;
private string filename;
private List<AssignmentDatabase> databases;

[XmlAttribute("Type")]
public int Type {
get {
return type;
}

set {
type = value;
}
}

[XmlAttribute("Ignore")]
public bool Ignore {
get {
return ignore;
}

set {
ignore = value;
}
}

[XmlAttribute("Name")]
public string Name {
get {
return name;
}

set {
name = value;
}
}

[XmlAttribute("Databases")]
public List<AssignmentDatabase> Databases {
get {
return databases;
}

set {
databases = value;
}
}

[XmlAttribute("Filename")]
public string Filename {
get {
return filename;
}

set {
filename = value;
}
}
}

public sealed partial class AssignmentDatabase {
private string database;

[XmlAttribute("Database")]
public string Database {
get {
return database;
}

set {
database = value;
}
}
}

wo liegt der Fehler? ist das ganze zu komplex für eine serialisierung?
Ich bin für jede Hilfe dankbar.

Grüße
Sascha

.



Relevant Pages

  • Re: OpenForm vs. Form menu double click.
    ... was a string and the data type of the where variable matched the syntax... ... In my situatiation the SSN on the input is text as well as the SSN field in ... A command button to add an assignment ... Private Sub Form_Open ...
    (microsoft.public.access.formscoding)
  • Re: Java or C++?
    ... Plus there are several toolkits and existing libraries available for Python. ... Take a string object for example. ... a copy constructor or assignment operator can be implemented when using C++. ... And if you want more control you can implement the default and copy constructors, destructor, and assignment operator, and tell them to do what you want. ...
    (comp.lang.python)
  • Re: Is a function a relation?
    ... update to being shortcuts for assignment. ... make it sound like they can suddenly spring into existence. ... That is a *selection* of a relation value. ... Consider the analogy of a textual string. ...
    (comp.databases.theory)
  • RE: Xml Serialisierung mit .Net 2 und Generics @Frank
    ... private Listdatabases; ... private Control control; ... private string name; ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Automating database table links with VBA for Query and Report
    ... You forgot the semicolon at the front of the connect string. ... The problem seems to be that the TableDef is read only when it exists in a TableDef collection, so I can't change the connect property. ... > Dim connectionString As String ... >> Unless you need to have three reporting databases for some reason, ...
    (microsoft.public.access.modulesdaovba)