Re: Hashtable remoting issue handling a struct, Why?

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

From: Allen Anderson (allen_at_sparkysystems.com)
Date: 05/10/04


Date: Mon, 10 May 2004 08:25:19 -0600

you need to add the files to the server so the client and server see
the same thing. Check out this article for more information.

http://www.glacialcomponents.com/ArticleDetail.aspx?articleID=RemoteObject

Allen Anderson
http://www.glacialcomponents.com
mailto: allen@put my website url here.com

On Mon, 10 May 2004 00:16:07 -0700, "A. Burch" <a1_dog@msn.com> wrote:

>Changing the Hashtable to pass a primitive like int, string, etc. works but
>the struct doesn't want to work. What is wrong?
>
>
>Error received.....
>
>An unhandled exception of type
>'System.Runtime.Serialization.SerializationException' occurred in
>mscorlib.dll
>
>Additional information: Cannot find the assembly Console, Version=0.0.0.0,
>Culture=neutral, PublicKeyToken=null.
>
>
>Here is my sample code......
>
>using System;
>using System.Collections;
>using System.Runtime.Remoting;
>using System.Runtime.Remoting.Channels;
>using System.Runtime.Remoting.Channels.Tcp;
>
>namespace Rem
>{
>
> [Serializable]
> struct SSG
> {
> public string sector;
> public string symbol;
> public double gain;
>
> public SSG(string sector, string symbol, double gain)
> {
> this.sector = sector;
> this.symbol = symbol;
> this.gain = gain;
> }
> }
>
>public class RemClient
>{
> public static void Main()
> {
> SSG Testit = new SSG("Hi", "Bye", 1.0);
> Testit.sector = "Barf";
> Testit.symbol = "Dog";
> Testit.gain = 33.0;
>
> Console.WriteLine ( "Create and register the channel...");
> TcpClientChannel tcpChannel = new TcpClientChannel();
> ChannelServices.RegisterChannel ( tcpChannel );
> Console.WriteLine("Registering remote object in local domain...");
> BaseRemoteObject obj =(BaseRemoteObject)
>Activator.GetObject(typeof(BaseRemoteObject),
>tcp://localhost:1313/RemInfo.soap");
>
> Console.WriteLine ("Create remote object and execute method");
> Hashtable HashClient = new Hashtable();
> obj.setObject(HashClient);
> Console.WriteLine("Get the HashClient");
> HashClient = obj.getObject();
> Console.WriteLine("Write the Testit structure");
> HashClient.Add("Test", Testit);
>*******************************<<<<<<<<< Exception is here
> Console.WriteLine("Send the Testit structure");
> obj.setObject(HashClient);
> Console.WriteLine("Finished the sending Testit struct");
> Console.WriteLine (" - press Enter key for exit...");
> Console.ReadLine ();
> }
> }
>}
>
>
>Shared DLL code ......
>
>using System;
>using System.Collections;
>using System.Runtime.Remoting.Messaging;
>namespace Rem
>{
> public abstract class BaseRemoteObject : MarshalByRefObject
> {
> public abstract void setObject(Hashtable val);
> public abstract Hashtable getObject();
> }
>}
>
>Server code......
>
>using System;
>using System.Collections;
>using System.Runtime.Remoting;
>using System.Runtime.Remoting.Channels;
>using System.Runtime.Remoting.Channels.Tcp;
>
>namespace Rem
>{
>
> public class RemInfo : BaseRemoteObject
> {
> Hashtable gvalue;
> public override void setObject(Hashtable val)
> {
> Console.WriteLine("RemInfo.setValue(): old {0} new {1}", gvalue,
>val);
> gvalue = val;
> }
> public override Hashtable getObject()
> {
> Console.WriteLine("RemInfo.getValue(): current {0}", gvalue);
> return(gvalue);
> }
> }
>
> public class RemServer
> {
> static void Main()
> {
> Console.WriteLine("Register remote object...");
> TcpServerChannel tcpChannel = new TcpServerChannel (1313);
> ChannelServices.RegisterChannel (tcpChannel);
> RemotingConfiguration.RegisterWellKnownServiceType (
> typeof(RemInfo),"RemInfo.soap",WellKnownObjectMode.Singleton);
>
> Console.WriteLine ( "Create & register the channel...");
> Console.WriteLine (" Waiting - press Enter key to exit...");
> Console.ReadLine();
> }
> }
>}
>
>



Relevant Pages

  • Re: Event Processing
    ... public class BroadcastEventWrapper: MarshalByRefObject ... static void Main ... Console.WriteLine("Event Server started, press to ... Client Code: ...
    (microsoft.public.dotnet.distributed_apps)
  • Re: Names of static types
    ... interface A_ ... public class Main ... public static void main(java.lang.Stringargs) ...
    (comp.lang.java.programmer)
  • Re: take a look ... its basic but its mine, all mine!!!
    ... private static void out{ ... Swing GUI components should be constructed and modified on the Event Dispatch Thread. ... public class Runner implements Runnable { ...
    (comp.lang.java.help)
  • Re: Generics ?
    ... public class KList extends JList { ... ListModel model = new DefaultListModel; ... public static void mainthrows Exception { ...
    (comp.lang.java.programmer)
  • Re: take a look ... its basic but its mine, all mine!!!
    ... private static void out{ ... Swing GUI components should be constructed and modified on the Event Dispatch Thread. ... public class Runner implements Runnable { ...
    (comp.lang.java.help)