I was reading the old forums and I'm wondering if I've just hit a wall. In certain use cases I need to serialize my object graph to an XML string for use by a specific UI layer. Do I have any options? Specifically:
Code:
[Serializable]
public class Foo {
private int id;
private string name;
private IList bars;
//the usual properties ...
public getXML() {
// code that creates memory stream, XmlTextWriter,
// XmlSerializer and returns utf string
}
}
[Serializable]
public class Bar {
private int id;
private string name;
private Foo foo;
//the usual properties ...
}
Mapping file:
Code:
<class name="Foo">
<id name="id" access="field">
<generator class="native" />
</id>
<property name="Name" />
<bag name="Bars">
<key column="BarID" />
<one-to-many class="Bar" />
</bag>
</class>
<class name="Bar">
<id name="id" access="field">
<generator class="native" />
</id>
<property name="Name" />
<many-to-one name="Foo" class="Foo" />
</class>
when i try to serialize this. the following exception is thrown:
Quote:
The type AssemblyName.Bar was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
any pointers would be welcomed with delight.
-devon