473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Remoting: assign a client handler to a remote event

6
I'm trying to get an event-handler relationship set up over a remote tcp connection. I have set the security level so that I can serialize any object (full). My server has a "game" object which has an event. The client has a user control that responds to the event through an intermediate "remoteReceiver" object that inherits MarshallbyRefObject. I'm getting "An error occurred while processing the request on the server: System.ArgumentNullException: No message was deserialized prior to calling the DispatchChannelSink." at "Game.testEvent += new Game.BlankEventHandler(remoteReceiver.fireTestEven t2);". Can anyone tell me how to fix this.

Server Code:
Expand|Select|Wrap|Line Numbers
  1. [Serializable]
  2.     public class Game : MarshalByRefObject
  3.     {
  4.         public Game()
  5.         {
  6.             // We create our own provider because we need to set the TYpeFilterLevel to full
  7.             // Without this, we can not pass objects to remote procedure calls.
  8.             SoapServerFormatterSinkProvider provider = new SoapServerFormatterSinkProvider();
  9.             provider.TypeFilterLevel = TypeFilterLevel.Full;
  10.             IDictionary props = new Hashtable();
  11.             props["port"] = Properties.Settings.Default.tcp_channel;
  12.             props["name"] = String.Empty;//"game";
  13.             // Register our channel on selected port
  14.             ChannelServices.RegisterChannel(new TcpChannel(props, null, provider), false);
  15.             // Register as an available service with the name 
  16.             RemotingServices.Marshal(this, "game");
  17.         }
  18.         [Serializable]
  19.         public delegate void BlankEventHandler();
  20.         public event BlankEventHandler testEvent;
  21.  
  22.         public void fireTestEvent()
  23.         {
  24.             testEvent();
  25.         }
  26.  
Client Code:
Expand|Select|Wrap|Line Numbers
  1.           // Connect to the game server
  2.             TcpChannel tcpChannel = new TcpChannel();
  3.             ChannelServices.RegisterChannel(tcpChannel, false);
  4.             Type requiredType = typeof(Game);
  5.             string port = Properties.Settings.Default.tcp_channel.ToString();
  6.             Game game = (Game)Activator.GetObject(requiredType, "tcp://" + ip + ":" + port + "/game");
  7.  
  8.             remoteReceiver = new RemoteReceiver();
  9.  
  10.             game.testEvent += new Game.BlankEventHandler(remoteReceiver.fireTestEvent2);
  11.             remoteReceiver.testEvent2 += new Game.BlankEventHandler(eventResponder);
  12.             game.fireTestEvent();
  13.  
Jul 5 '07 #1
0 990

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nick | last post by:
Is there a way that if I host my remoted object in IIS (not having to mess with encryption & authentication via a custom sink) that the server can raise events and the clients can detect them? If...
1
by: Dan Cimpoiesu | last post by:
I have a remoting object, derived from MarshalByRefComponent, that I instantiate on the client side, with Activator.GetObject. Can I receive events fired on the server, on the client? How?
15
by: Sharon | last post by:
I’m trying to build a generic Publisher-Subscriber that will work over the net, so I’m using the Remoting. I wish that the subscriber user will be notify about the messages sent by the...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
3
by: Steve | last post by:
I've been following a couple remoting tutorials on the web, they are all pretty much the same. I've got my different applications built(client, server and remote object (dll)) The client is...
4
by: Sharon | last post by:
Hi, I'm using the remoting, and I have a remoting object that has a public event that other processes should register to it. But when the client process is registering to the remote event, it...
3
by: S Chapman | last post by:
I have a simple remote server object that raises an event when the list maintined by it changes. The idea is to enable the remote client to update the GUI when the server list changes. When the I...
4
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
2
by: erbilkonuk | last post by:
Hi, I am very new to .NET Remoting and I try to run a simple program to subscribe to an event raised by Remoting Class. The Remoting Server initiates an instance of Remoting Class as Singleton /...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.