473,568 Members | 3,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remoting: assign a client handler to a remote event

6 New Member
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 MarshallbyRefOb ject. I'm getting "An error occurred while processing the request on the server: System.Argument NullException: No message was deserialized prior to calling the DispatchChannel Sink." at "Game.testE vent += new Game.BlankEvent Handler(remoteR eceiver.fireTes tEvent2);". 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 998

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

Similar topics

2
1898
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 so what would be the best way to go about having the client handle an event that is fired from the server...I am currently using SingleCall and not...
1
10500
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
5733
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 remote publisher, so I used delegate that the user will be able to set on it his own function for that purpuse. The trouble is that this delegate must...
4
3107
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 it a go). What I want to do is this: Have a server instance of the program, this server instance will receive communication from client programs...
3
2862
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 able to get a reference to the remote object and that works fine. When I try to make a call to a remote object's method I get an exception:...
4
2254
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 throw the following exception: System.Runtime.Serialization.SerializationException {“Cannot find the assembly Tester, Version=1.0.2164.27180,...
3
1501
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 create the server object without using remoting (i.e. just use new()) the event fires and the client updates the UI but when I create the server...
4
6628
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
2
3046
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 / Server activated mode on startup. The Remoting Client accesses the Remoting Class through the interface of the Class and subscribes to an event of...
0
7693
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7605
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.