473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

XmlSerializer and delegates

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.

May 11 '07 #1
2 2484
http://msdn2.microsoft.com/en-us/lib...er(VS.71).aspx
Husam Al-A'araj

"Beorne" wrote:
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.

May 11 '07 #2
On 11 Mag, 18:27, Husam Al-A''araj
<HusamAlAa...@discussions.microsoft.comwrote:
http://msdn2.microsoft.com/en-us/lib...ialization.xml...

Husam Al-A'araj

"Beorne" wrote:
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.

May 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Stuart Robertson | last post by:
I am trying to find a solution that will allow me to use XmlSerializer to serialize/deserialize a collection of objects where a given object is shared between two or more other objects, and not...
1
by: Bluetears76 | last post by:
Hi I have a hirachy of classes which are Message(base), then FileMessage and ChatMessage (extended) I want to serialize the objects and when i am deserizaling i dont know if i am getting...
3
by: Anthony Bouch | last post by:
Hi I've been reading using the XmlSerializer with custom collections. I've discovered that when serializing a custom collection (a class that implements ICollection, IList etc.) the...
4
by: Andy Neilson | last post by:
I've run across a strange behaviour with XmlSerializer that I'm unable to explain. I came across this while trying to use XmlSerializer to deserialize from a the details of a SoapException. This...
3
by: Loui Mercieca | last post by:
Hi, I have created a class, named FormField , which basically contains two fields, name and value. I have set the tag before the class and the field is set as an XmlAttribute whil the name as...
12
by: SJD | last post by:
I've just read Christoph Schittko's article on XmlSerializer: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnxmlnet/html/trblshtxsd.asp . . . and very informative it is too....
4
by: Steve Long | last post by:
Hello, I hope this is the right group to post this to. I'm trying to serialize a class I've written and I'd like to be able to serialze to both binary and xml formats. Binary serialization is...
0
by: Daniel Lindros via .NET 247 | last post by:
Hi! I am currently trying to learn C#, and have started by developinga simple messaging application with a client and server. Byusing callback delegates, I can asynchronously send and recievetext...
0
by: William Stacey [MVP] | last post by:
Had a method that got some string info from mp3 tags in N files and serializes this class and deserializes at other side. Works ok except sometimes get chars that choke the XmlSerializer. After...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.