Re: Problem with serializing business object instead of core objects
From: Fred Hirschfeld (a_at_b.c)
Date: 09/18/04
- Next message: Alex: "Re: Problem with serializing business object instead of core objec"
- Previous message: 0to60: "My object's remoting proxy is WAY huge on the client"
- In reply to: Ken Kolda: "Re: Problem with serializing business object instead of core objects"
- Next in thread: Alex: "Re: Problem with serializing business object instead of core objec"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 18 Sep 2004 08:34:23 -0700
I was also getting this and it should be noted that if you are using
interfaces (in a separate assembly or not), you will NOT be able to pass by
value (Serialized) but rather will have to derive the base class from
MarshalByRefObejct. The downside to this is that you call the server for
EVERY property get/set and method access, BUT the gain is that you have 0
code implementation deployed to the client.
If you are always calling methods and passing everything needed, then
interfaces may work well for you. I had to change my code to implement those
parts needed at the client (basically just structs to send data back and
forth) in a separate DLL that is used by both the server and client.
Hope this helps a bit, I am new to Remoting but came across this early.
Fred
"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> wrote in message
news:uZfT8wQnEHA.3076@TK2MSFTNGP15.phx.gbl...
> My guess is that you have defined the RemoteTest class twice -- once in
your
> server assembly and once in the client assembly. Since the assembly name
is
> part of the full name of a class (which is passed as part of the
> serialization info), these type definitions will not be recognized as the
> same, even if the namespaces and the class names are exactly the same in
the
> client and server assemblies. To solve this, put this class definition in
a
> separate assembly which will be shared by both client and server.
>
> That said, it looks like you must already be doing this to some degree
since
> your able to use the IApptikRemoteCache interface (which I assume is in a
> separate assembly). So, if what I described above isn't the problem, let
me
> know.
>
> Ken
>
>
> "Alex" <Alex@discussions.microsoft.com> wrote in message
> news:C7DC2C7D-30D4-457B-95E4-418037C0FE7F@microsoft.com...
> > I have created a simple remoting client-server setup where I am having
> > problems when attempting to deal with business objects. If I run the
> client
> > and server, and pass in a standard object such as a string, integer,
guid,
> > etc., everything works fine. However, if I try to pass in a business
> object
> > that I have marked as serializable, I get the following error:
> >
> > Unable to find assembly '__codeyqhbdlhs, Version=0.0.0.0,
Culture=neutral,
> > PublicKeyToken=null'.
> >
> > I have marked the business object as serializable and to test, I created
a
> > simple business object that just has a couple of string fields. The
error
> > also appears to occur when I try to run deserialize or serialize
directly
> on
> > an object instead of allowing the framework to handle the serialization
so
> > the problem seems to be serialization. The same error occurs whether I
> use
> > Binary or SOAP formatters. I am running my server as a windows app.
The
> > relevant code to activate remoting on the server is as follows:
> >
> > private void button1_Click(object sender, EventArgs e)
> > {
> > BinaryServerFormatterSinkProvider ServerProvider = new
> > BinaryServerFormatterSinkProvider();
> > TcpServerChannel tsc = new TcpServerChannel("TCPChannel",
> 7777,
> > ServerProvider);
> > ChannelServices.RegisterChannel(tsc);
> >
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ApptikRemoteObject
> ), "ApptikCache", WellKnownObjectMode.SingleCall);
> >
> > infobox.Items.Add("Initializing cache server initialized");
> >
> >
> > stopped = false;
> >
> > }
> >
> > }
> >
> >
> > The relevant client portion is run from an asp page and is as follows:
> >
> > Global.asax
> >
System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider
> > ClientProvider = new
> > System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider();
> > System.Runtime.Remoting.Channels.Tcp.TcpClientChannel tsc = new
> > System.Runtime.Remoting.Channels.Tcp.TcpClientChannel("TCPChannel",
> > ClientProvider);
> >
> System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(tsc);
> >
> > appobject.aspx
> >
> > IApptikRemoteCache remoteobj =
> > (IApptikRemoteCache)Activator.GetObject(typeof(IApptikRemoteCache),
> > "tcp://localhost:7777/ApptikCache");
> >
> > RemoteTest findtestvalue = (RemoteTest)
> > remoteobj.Find("RemoteTestTest11");
> > if (findtestvalue == null)
> > {
> >
> > HttpContext.Current.Trace.Write("Test not found");
> > // if I pass a string in the next line instead of remotetest
> object
> > // then everything works fine
> > RemoteTest test = new RemoteTest();
> > remoteobj.Add("RemoteTestTest11", test, null);
> > }
> > else
> > {
> >
> > HttpContext.Current.Trace.Write("Test " +
> > findtestvalue.Test2.ToString());
> >
> > }
> >
> > The remote class that I am attempting to pass through is as follows:
> >
> > [Serializable]
> > public class RemoteTest {
> >
> > private string test = string.Empty;
> > private string test2 = string.Empty;
> > public string Test2
> > {
> > get
> > {
> > return test2;
> > }
> >
> > set
> > {
> > test2 = value;
> > }
> > }
> >
> >
> > public RemoteTest()
> > {
> >
> > test2 = "Palookaville";
> >
> > }
> >
> > }
> >
> >
> >
>
>
- Next message: Alex: "Re: Problem with serializing business object instead of core objec"
- Previous message: 0to60: "My object's remoting proxy is WAY huge on the client"
- In reply to: Ken Kolda: "Re: Problem with serializing business object instead of core objects"
- Next in thread: Alex: "Re: Problem with serializing business object instead of core objec"
- Messages sorted by: [ date ] [ thread ]