473,769 Members | 2,402 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About the remoting event

in a remoting application, i set a event in the host, and let the client to
book it, and in the host side i set the TypeFilterLevel to Full and open the
callback port in the client side, but told that these was an exception on the
invoked object.
can anyone tell my why? It is a very simple application just to test, and
here is the code, i am using vs2008, thanx in advaned.

----------server side----------------------
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Runtime. Remoting;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Ipc;
using System.Runtime. Remoting.Channe ls.Tcp;
using System.Runtime. Serialization.F ormatters;
using System.IO;
using System.Collecti ons;

namespace RcServer
{
class Program
{
static void Main(string[] args)
{
IDictionary pros = new Hashtable();
pros["portName"] = "host";
BinaryServerFor matterSinkProvi der ss = new
BinaryServerFor matterSinkProvi der();
ss.TypeFilterLe vel = TypeFilterLevel .Full;
IChannel cnl = new IpcChannel(pros , new
BinaryClientFor matterSinkProvi der(), ss);

ChannelServices .RegisterChanne l(cnl, false);
RemotingConfigu ration.Register WellKnownServic eType(typeof(Ca t),
"cat", WellKnownObject Mode.Singleton) ;
Cat cat = new Cat();
Console.WriteLi ne("go");
Console.ReadLin e();
}
}
public class Cat : MarshalByRefObj ect
{
public event EventHandler OnScreaming;
public void Scream()
{
Console.WriteLi ne("i am wake");
if (this.OnScreami ng != null)
this.OnScreamin g(this,null);
}

}
}

----------------client side-------------------------
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Runtime. Remoting;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Ipc;
using System.Runtime. Serialization.F ormatters;
using System.Collecti ons;
using RcServer;

namespace RcClient
{
class Program
{
static void Main(string[] args)
{
IChannel cnl = new IpcChannel("MyC allback");
ChannelServices .RegisterChanne l(cnl, false);
RemotingConfigu ration.Register WellKnownClient Type(typeof(Cat ),
@"ipc://host/cat");
Cat c = (Cat)Activator. CreateInstance( typeof(Cat));
Rat jy = new Rat();
jy.ThereIsaCat( c);
c.Scream();

}
}

[Serializable]
public class Rat:MarshalByRe fObject
{
public void ThereIsaCat(Cat cat)
{
cat.OnScreaming += new EventHandler(th is.cat_OnScream ing);
}
void cat_OnScreaming (object sender, EventArgs e)
{
Console.WriteLi ne("cat's awake, run quick!");
}
}
}

Jul 1 '08 #1
2 3513
I find that using events is a PITA when using remoting. Rather, I would
define a callback interface that the client implements, and then make sure
that the class that implements it derives from MarshalByRefObj ect, and send
that to the server to call back onto when you want to fire an event. It's
much cleaner, and it works.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"fairyvoice " <fa********@dis cussions.micros oft.comwrote in message
news:46******** *************** ***********@mic rosoft.com...
in a remoting application, i set a event in the host, and let the client
to
book it, and in the host side i set the TypeFilterLevel to Full and open
the
callback port in the client side, but told that these was an exception on
the
invoked object.
can anyone tell my why? It is a very simple application just to test, and
here is the code, i am using vs2008, thanx in advaned.

----------server side----------------------
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Runtime. Remoting;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Ipc;
using System.Runtime. Remoting.Channe ls.Tcp;
using System.Runtime. Serialization.F ormatters;
using System.IO;
using System.Collecti ons;

namespace RcServer
{
class Program
{
static void Main(string[] args)
{
IDictionary pros = new Hashtable();
pros["portName"] = "host";
BinaryServerFor matterSinkProvi der ss = new
BinaryServerFor matterSinkProvi der();
ss.TypeFilterLe vel = TypeFilterLevel .Full;
IChannel cnl = new IpcChannel(pros , new
BinaryClientFor matterSinkProvi der(), ss);

ChannelServices .RegisterChanne l(cnl, false);
RemotingConfigu ration.Register WellKnownServic eType(typeof(Ca t),
"cat", WellKnownObject Mode.Singleton) ;
Cat cat = new Cat();
Console.WriteLi ne("go");
Console.ReadLin e();
}
}
public class Cat : MarshalByRefObj ect
{
public event EventHandler OnScreaming;
public void Scream()
{
Console.WriteLi ne("i am wake");
if (this.OnScreami ng != null)
this.OnScreamin g(this,null);
}

}
}

----------------client side-------------------------
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Runtime. Remoting;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Ipc;
using System.Runtime. Serialization.F ormatters;
using System.Collecti ons;
using RcServer;

namespace RcClient
{
class Program
{
static void Main(string[] args)
{
IChannel cnl = new IpcChannel("MyC allback");
ChannelServices .RegisterChanne l(cnl, false);
RemotingConfigu ration.Register WellKnownClient Type(typeof(Cat ),
@"ipc://host/cat");
Cat c = (Cat)Activator. CreateInstance( typeof(Cat));
Rat jy = new Rat();
jy.ThereIsaCat( c);
c.Scream();

}
}

[Serializable]
public class Rat:MarshalByRe fObject
{
public void ThereIsaCat(Cat cat)
{
cat.OnScreaming += new EventHandler(th is.cat_OnScream ing);
}
void cat_OnScreaming (object sender, EventArgs e)
{
Console.WriteLi ne("cat's awake, run quick!");
}
}
}

Jul 1 '08 #2
thanks Nicholas, when you said "callback interface" did you mean the one in
the asynchronous model, i am not very clear.
May you tell me more precisely or show me a few codes? thanx

"Nicholas Paldino [.NET/C# MVP]" wrote:
I find that using events is a PITA when using remoting. Rather, I would
define a callback interface that the client implements, and then make sure
that the class that implements it derives from MarshalByRefObj ect, and send
that to the server to call back onto when you want to fire an event. It's
much cleaner, and it works.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"fairyvoice " <fa********@dis cussions.micros oft.comwrote in message
news:46******** *************** ***********@mic rosoft.com...
in a remoting application, i set a event in the host, and let the client
to
book it, and in the host side i set the TypeFilterLevel to Full and open
the
callback port in the client side, but told that these was an exception on
the
invoked object.
can anyone tell my why? It is a very simple application just to test, and
here is the code, i am using vs2008, thanx in advaned.

----------server side----------------------
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Runtime. Remoting;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Ipc;
using System.Runtime. Remoting.Channe ls.Tcp;
using System.Runtime. Serialization.F ormatters;
using System.IO;
using System.Collecti ons;

namespace RcServer
{
class Program
{
static void Main(string[] args)
{
IDictionary pros = new Hashtable();
pros["portName"] = "host";
BinaryServerFor matterSinkProvi der ss = new
BinaryServerFor matterSinkProvi der();
ss.TypeFilterLe vel = TypeFilterLevel .Full;
IChannel cnl = new IpcChannel(pros , new
BinaryClientFor matterSinkProvi der(), ss);

ChannelServices .RegisterChanne l(cnl, false);
RemotingConfigu ration.Register WellKnownServic eType(typeof(Ca t),
"cat", WellKnownObject Mode.Singleton) ;
Cat cat = new Cat();
Console.WriteLi ne("go");
Console.ReadLin e();
}
}
public class Cat : MarshalByRefObj ect
{
public event EventHandler OnScreaming;
public void Scream()
{
Console.WriteLi ne("i am wake");
if (this.OnScreami ng != null)
this.OnScreamin g(this,null);
}

}
}

----------------client side-------------------------
using System;
using System.Collecti ons.Generic;
using System.Linq;
using System.Text;
using System.Runtime. Remoting;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Ipc;
using System.Runtime. Serialization.F ormatters;
using System.Collecti ons;
using RcServer;

namespace RcClient
{
class Program
{
static void Main(string[] args)
{
IChannel cnl = new IpcChannel("MyC allback");
ChannelServices .RegisterChanne l(cnl, false);
RemotingConfigu ration.Register WellKnownClient Type(typeof(Cat ),
@"ipc://host/cat");
Cat c = (Cat)Activator. CreateInstance( typeof(Cat));
Rat jy = new Rat();
jy.ThereIsaCat( c);
c.Scream();

}
}

[Serializable]
public class Rat:MarshalByRe fObject
{
public void ThereIsaCat(Cat cat)
{
cat.OnScreaming += new EventHandler(th is.cat_OnScream ing);
}
void cat_OnScreaming (object sender, EventArgs e)
{
Console.WriteLi ne("cat's awake, run quick!");
}
}
}


Jul 2 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1908
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 Singleton.
1
10522
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?
2
5861
by: wobbles | last post by:
Hi Everyone (Happy New Year!), If I have clients that want to tell the server that something has happened, what would be the difference between "remoting events" and using an asynchronous (one way) call? If I use an event, my server would use that event to "DoSomething" on the server. Similarly if I used an Async one way call, that would invoke a server-side method that would also "DoSomething".
15
5753
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 not be static because there may be many subscribers, and each subscriber may have different...
3
2087
by: S.Creek | last post by:
Hi, I am trying to build a multi clients application with C# that will send and receive messages using a listener on a server, the computers are all on the same LAN, the listener need to identify a message in the MS Queues he listens on, and send it to the relevant clients (not all need to get all messages) it can send the message through an event or an interface.?
4
2265
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, Culture=neutral, PublicKeyToken=null.”}
6
1627
by: AMDRIT | last post by:
Hello folks, I appologize for the cross post, but I really need an answer on this: I do not think that I am seeing the whole picture here. I would like to create a windows service and a management console, using Visual Basic 2003. The windows service part, I think, is easy enough. I am more concerned with the remoting aspect of the project. Below is the general idea of my approach, please correct my where I am wrong.
3
1507
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 object as a remote object (using Activator.GetObject()) the event does not fire at all. I have pasted...
4
6650
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
0
9586
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9423
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10043
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9861
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5298
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3561
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.