BizTalk Server Orchestration - Re: Property Fields in .Net Classes... ANOTHER Compile Error-"XML-SERIALIZABLE&q

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > June 2004 > Re: Property Fields in .Net Classes... ANOTHER Compile Error-"XML-SERIALIZABLE&q





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Property Fields in .Net Classes... ANOTHER Compile Error-"XML-SERIALIZABLE&q
Hong Lee

2004-06-30, 8:49 pm

I added a default constructor.
(Here is my class...)

[Serializable]
public class POClass {
[Property(typeof(PropertySchemas.IDs))]
public string ID;

public string Item;
public POClass() { }
}


Still...
a compile error "a class must have a default constructor to be serialized by
mlSerializer" reported.


I think...

Although there is no default constructor specified in class definition...
default constructor is provided implicitly when there is no any other
constructors.

so...
"a class must have a default constructor to be serialized by XmlSerializer"
means...a class should not be like this...
public class POClass {
[Property(typeof(PropertySchemas.IDs))]
public string ID;

public string Item;
public POClass(string s) { ID = s; }
}


So...
I solved the xml-serializable problem
by adding an attribute that control XML serialization....


[Serializable]
public class POClass
{
[Property(typeof(PropertySchemas.IDs))]
[XmlRootAttribute("PO")]
public string ID;

public string Item;
}

I feel...
this is not the right way to solve the compile error.

Plz...
comment me more...


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com