Serialization problem

P

Picho

Hi all.

Trying to serialize and desirialize an object. the object is transfered as a
byte[] using a web service to the client. the client then has to deserialize
the byte[] to an object and work with it.

the object has a not-so-complicated graph constructed from several classes i
made and fields of mostly simple types (string, int, enums) and bitmaps.

I am getting an error on the client side saying "Object type cannot be
converted to target type."

I was afraid that since some of the properties are defined only as "get",
the formatter cant reconstruct object state. to verify that, I added a line
in the web service that desirializes the object too, and that works. seems
like the "traffic on the web" (lol) has damaged the object?

both web service and client use the same dll that holds the classes and the
same version.

any ideas?

thanx,

picho
 
P

Patrick Steele [MVP]

Hi all.

Trying to serialize and desirialize an object. the object is transfered as a
byte[] using a web service to the client. the client then has to deserialize
the byte[] to an object and work with it.

the object has a not-so-complicated graph constructed from several classes i
made and fields of mostly simple types (string, int, enums) and bitmaps.

I am getting an error on the client side saying "Object type cannot be
converted to target type."

I was afraid that since some of the properties are defined only as "get",
the formatter cant reconstruct object state. to verify that, I added a line
in the web service that desirializes the object too, and that works. seems
like the "traffic on the web" (lol) has damaged the object?

both web service and client use the same dll that holds the classes and the
same version.

If both client and server will be running .NET, you'll probably get
better performance (and less problems) using remoting. The
serialization will done for you by the remoting framework. Your code
can be as simple as:

MyServerObject server = new MyServerObject();
server.Method1();
server.Method3(4, 3);

Yet "MyServerObject" is an object on a remote server.
 
P

Picho

Thank you Patrick for your reply.

I understand that remoting can work in tcp cahnnel as well?

how can I ensure security that is if the object state holds confidential
info.
what I did with the web service is serializing and then encrypting so I felt
it was a secure way.

Patrick Steele said:
Hi all.

Trying to serialize and desirialize an object. the object is transfered as a
byte[] using a web service to the client. the client then has to deserialize
the byte[] to an object and work with it.

the object has a not-so-complicated graph constructed from several classes i
made and fields of mostly simple types (string, int, enums) and bitmaps.

I am getting an error on the client side saying "Object type cannot be
converted to target type."

I was afraid that since some of the properties are defined only as "get",
the formatter cant reconstruct object state. to verify that, I added a line
in the web service that desirializes the object too, and that works. seems
like the "traffic on the web" (lol) has damaged the object?

both web service and client use the same dll that holds the classes and the
same version.

If both client and server will be running .NET, you'll probably get
better performance (and less problems) using remoting. The
serialization will done for you by the remoting framework. Your code
can be as simple as:

MyServerObject server = new MyServerObject();
server.Method1();
server.Method3(4, 3);

Yet "MyServerObject" is an object on a remote server.
 
P

Patrick Steele [MVP]

Thank you Patrick for your reply.

I understand that remoting can work in tcp cahnnel as well?

how can I ensure security that is if the object state holds confidential
info.
what I did with the web service is serializing and then encrypting so I felt
it was a secure way.

See this MSDN article:

http://tinyurl.com/6zy5z
 

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