Re: Serialization problem

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Patrick Steele [MVP] (patrick_at_mvps.org)
Date: 07/27/04


Date: Tue, 27 Jul 2004 12:04:08 -0400

In article <OgSrkn9cEHA.1656@TK2MSFTNGP09.phx.gbl>,
SPAM_picho@telhai.ac.il says...
> 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.

-- 
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele


Relevant Pages

  • Re: Problem with serializing business object instead of core objec
    ... > do this since the server does not need to know the type of object I am ... than you have to serialize the objects ... on the client and send them as binary data to the server. ... >>client and server assemblies. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Book recommendations for database development
    ... You then serialize that object (Class instance) across ... your TCP connection to your Application Server (a TCP socket server you ...
    (borland.public.delphi.non-technical)
  • Re: GC, Windows or Design problem?
    ... >> on the server? ... Did you use C# (or any other managed code) to do this on ... formatter used, for instance the xml serializer produces much larger files ... What formatter did you use to serialize? ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: A cryptography solution for a client/server winforms app
    ... the client or server could then do the same after decrypting the data to ... determine if it would be safe to attempt to serialize it. ... encrypt the memory stream. ...
    (microsoft.public.dotnet.security)