List Info

Thread: Serializing a datarow in webservices




Serializing a datarow in webservices
user name
2006-10-18 14:03:41
On 10/18/06, Manoj Aggarwal <manoj.agggmail.com> wrote:
> Can you please explain why is it so...
> Also It will be helpful if u can explain what is
"datarow with parameterless
> constructor", an example will help me a long way

The .net framework must be able to construct a class from it
serialized form.
In other words the class must be deserializable.
Therefor it mandate the class to have a parameterless
constructor.

class Foo
{
public Foo() { /* do something neat */ }
}

class Bar
{
public Bar(int value) { /* do something neat */ }
}

class Bar doesnt have a parameterless ctor, it wants an int.
The .net framework cannot simple know what value it should
pass,
therefor it can deserialize class Foo but not class Bar.

HTH
// Ryan

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Serializing a datarow in webservices
user name
2006-10-18 14:16:45
> On 10/18/06, Manoj Aggarwal <manoj.agggmail.com> wrote:
> > Can you please explain why is it so...
> > Also It will be helpful if u can explain what is
"datarow with
> > parameterless constructor", an example will
help me a long way
>
> The .net framework must be able to construct a class
from it
> serialized form.
> In other words the class must be deserializable.
> Therefor it mandate the class to have a parameterless
constructor.
>
> class Foo
> {
> public Foo() { /* do something neat */ } }
>
> class Bar
> {
> public Bar(int value) { /* do something neat */ } }
>
> class Bar doesnt have a parameterless ctor, it wants an
int.
> The .net framework cannot simple know what value it
should
> pass, therefor it can deserialize class Foo but not
class Bar.

        sure it can, though the XmlSerializer can't (at
least in .net 1.x). The remoting formatters can. I have
classes marked with
[Serializable] and with solely parameter using constructors.
And they serialize fine (without ISerializable
requirements).

        As the TS talked about webservices, I think it's
good to distinguish remoting serialization and xml
serialization as these
are not related 

                FB

===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )