Christoph Schittko
11/1/2002 4:13:00 PM
They are serializable with the BinaryFormatter or the SoapFormatter. The
does not mean that they are necessarily also serializable with the
XmlSerializer.
The XmlSerializer is not really targetted for object persistance, but more
for data binding situations, i.e. parse or create XML documents conforming
to a certain schema. It imposes certain restrictions on the classes it can
process: the class needs a default constructor, it only serializes public
fields and properties and a few more, which makes it not very usable to
serialize classes that were not specifically designed be processed by the
XML serializer.
Check out the System.Runtime.Serialization namespace for serializers that
can serialize every class marked with the [Serializable] attribute.
HTH,
--
Christoph Schittko
Software Architect
"J. Osborne" <xenite@passport.com> wrote in message
news:2d6001c28177$065fd3f0$36ef2ecf@tkmsftngxa12...
> The dox for System.IO.FileInfo say that this class is
> serializable. However, when I try to create a new
> XMLSerializer:
>
> XmlSerializer s = new XmlSerializer(typeof
> (System.IO.FileInfo));
>
> I get an exception:
>
> An unhandled exception of
> type 'System.InvalidOperationException' occurred in
> system.xml.dll
>
> Additional information: There was an error
> reflecting 'System.IO.FileInfo'.
>
> Further inspection tells me that the reason for this is
> the class has no default constructor.
>
> What am I doing wrong?
>
> Thanks.
> -J