XmlSerializer and delegates

B

Beorne

I'm serializing a class using XmlSerializer. I'm forced to use
XmlSerializer because I'm working on compact framework and this is the
only serialization supported.
When I try to serialize a class with some delegate type member it
gives me an exception saying the member class should have a default
constructor (????). but the member class is a delegate ...
Example:
-----------------------------------------------------
[Serializable]
public static class DelegateContainer
{
public delegate void CustomDelegate(void);
}

[Serializable]
public class ClassToSerialize
{
DelegateContainer.CustomDelegate member = null;
}

------------------------------------------------------

When I serialize ClassToSerialize it gives me an exception saying
CustomDelegate should have a default constructor.

How could I do?
Thank you.
 
B

Beorne

http://msdn2.microsoft.com/en-us/library/system.xml.serialization.xml...

Husam Al-A'araj

Beorne said:
I'm serializing a class using XmlSerializer. I'm forced to use
XmlSerializer because I'm working on compact framework and this is the
only serialization supported.
When I try to serialize a class with somedelegatetype member it
gives me an exception saying the member class should have a default
constructor (????). but the member class is adelegate...
Example:
-----------------------------------------------------
[Serializable]
public static class DelegateContainer
{
publicdelegatevoid CustomDelegate(void);
}
[Serializable]
public class ClassToSerialize
{
DelegateContainer.CustomDelegate member = null;
}
------------------------------------------------------

When I serialize ClassToSerialize it gives me an exception saying
CustomDelegate should have a default constructor.
How could I do?
Thank you.

Sorry, I haven't understood how to use XmlAttributeEventHandler to
serialize a delegate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top