473,725 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET Remoting, Event Subscription to the Remoting Object / Subscribed event does not fire...

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
the Remoting Class that will be fired upon the private member value
change.

The problem is that I can not get the subscribed event fired. Do I
miss a point about Client Registration / Server Registration such
that
2 instances are created, 1 on Server Side, 1 on Client Side and the
event subscription is done on the wrong one? Please help :) Thanks in
advance...
[Remoting Class]
public class NetworkElement : MarshalByRefObj ect, INetworkElement
{
public event AlarmEventHandl er AlarmEvent;
private Boolean _ACFail;
public Boolean ACFail
{
get { return _ACFail; }
set
{
_ACFail = value;
OnAlarmsEvent(n ew AlarmEventArgs( 1));
}
}
protected void OnAlarmsEvent(A larmEventArgs arg)
{
if (AlarmEvent != null) AlarmEvent(this , arg);
}
public void AddAlarmEvent(A larmEventHandle r handler)
{
AlarmEvent += handler;
}
}
[Interface for Remoting Class]
public delegate void AlarmEventHandl er(object sender,
AlarmEventArgs arg);
[Serializable]
public class AlarmEventArgs : EventArgs
{
private Int32 _AlarmType;
public Int32 AlarmType
{
get { return _AlarmType; }
}
public AlarmEventArgs( Int32 Type)
{
_AlarmType = Type;
}
}
public interface INetworkElement
{
void AddAlarmEvent(A larmEventHandle r handler);
}
[The Remoting Client]
public class Client : MarshalByRefObj ect
{
public void SubscribeToAlar mEvent()
{
RemotingConfigu ration.Configur e("Client.exe.c onfig");
WellKnownClient TypeEntry[] entry =
RemotingConfigu ration.GetRegis teredWellKnownC lientTypes();
INetworkElement ine =
(INetworkElemen t)Activator.Get Object(entry[0].ObjectType,
entry[0].ObjectUrl);
ine.AddAlarmEve nt(new
AlarmEventHandl er(ClientEventH andler));
AlarmType = -1;
}
public void ClientEventHand ler(object sender, AlarmEventArgs
arg)
{
AlarmType = arg.AlarmType;
}
}
config files are :
[Server.exe.conf ig]
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.runtime .remoting>
<application>
<channels>
<channel port="6000" displayName="Se rverChannel" ref="tcp">
<serverProvider s>
<formatter ref="binary" typeFilterLevel ="Full"</
formatter>
</serverProviders >
<clientProvider s>
<formatter ref="binary"></formatter>
</clientProviders >
</channel>
</channels>
<service>
<wellknown type="NetworkE. NetworkElement, NetworkElement"
objectUri="Netw orkElement.rem" mode="Singleton ">
</wellknown>
</service>
</application>
</system.runtime. remoting>
</configuration>
[Client.exe.conf ig]
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.runtime .remoting>
<application>
<channels>
<channel port="0" displayName="Cl ientChannel" ref="tcp">
<clientProvider s>
<formatter ref="binary"></formatter>
</clientProviders >
<serverProvider s>
<formatter ref="binary" typeFilterLevel ="Full"></
formatter>
</serverProviders >
</channel>
</channels>
<client>
<wellknown type="INetworkE .INetworkElemen t, INetworkElement "
url="tcp://localhost:6000/NetworkElement. rem">
</wellknown>
</client>
</application>
</system.runtime. remoting>
</configuration>

Apr 13 '07 #1
2 3057
This is a common question - see
http://www.google.sk/search?hl=sk&q=...g+events&meta= with many
relevant results.

"erbilkonuk " <er********@gma il.comwrote in message
news:11******** **************@ y80g2000hsf.goo glegroups.com.. .
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
the Remoting Class that will be fired upon the private member value
change.

The problem is that I can not get the subscribed event fired. Do I
miss a point about Client Registration / Server Registration such
that
2 instances are created, 1 on Server Side, 1 on Client Side and the
event subscription is done on the wrong one? Please help :) Thanks in
advance...
[Remoting Class]
public class NetworkElement : MarshalByRefObj ect, INetworkElement
{
public event AlarmEventHandl er AlarmEvent;
private Boolean _ACFail;
public Boolean ACFail
{
get { return _ACFail; }
set
{
_ACFail = value;
OnAlarmsEvent(n ew AlarmEventArgs( 1));
}
}
protected void OnAlarmsEvent(A larmEventArgs arg)
{
if (AlarmEvent != null) AlarmEvent(this , arg);
}
public void AddAlarmEvent(A larmEventHandle r handler)
{
AlarmEvent += handler;
}
}
[Interface for Remoting Class]
public delegate void AlarmEventHandl er(object sender,
AlarmEventArgs arg);
[Serializable]
public class AlarmEventArgs : EventArgs
{
private Int32 _AlarmType;
public Int32 AlarmType
{
get { return _AlarmType; }
}
public AlarmEventArgs( Int32 Type)
{
_AlarmType = Type;
}
}
public interface INetworkElement
{
void AddAlarmEvent(A larmEventHandle r handler);
}
[The Remoting Client]
public class Client : MarshalByRefObj ect
{
public void SubscribeToAlar mEvent()
{
RemotingConfigu ration.Configur e("Client.exe.c onfig");
WellKnownClient TypeEntry[] entry =
RemotingConfigu ration.GetRegis teredWellKnownC lientTypes();
INetworkElement ine =
(INetworkElemen t)Activator.Get Object(entry[0].ObjectType,
entry[0].ObjectUrl);
ine.AddAlarmEve nt(new
AlarmEventHandl er(ClientEventH andler));
AlarmType = -1;
}
public void ClientEventHand ler(object sender, AlarmEventArgs
arg)
{
AlarmType = arg.AlarmType;
}
}
config files are :
[Server.exe.conf ig]
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.runtime .remoting>
<application>
<channels>
<channel port="6000" displayName="Se rverChannel" ref="tcp">
<serverProvider s>
<formatter ref="binary" typeFilterLevel ="Full"</
formatter>
</serverProviders >
<clientProvider s>
<formatter ref="binary"></formatter>
</clientProviders >
</channel>
</channels>
<service>
<wellknown type="NetworkE. NetworkElement, NetworkElement"
objectUri="Netw orkElement.rem" mode="Singleton ">
</wellknown>
</service>
</application>
</system.runtime. remoting>
</configuration>
[Client.exe.conf ig]
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.runtime .remoting>
<application>
<channels>
<channel port="0" displayName="Cl ientChannel" ref="tcp">
<clientProvider s>
<formatter ref="binary"></formatter>
</clientProviders >
<serverProvider s>
<formatter ref="binary" typeFilterLevel ="Full"></
formatter>
</serverProviders >
</channel>
</channels>
<client>
<wellknown type="INetworkE .INetworkElemen t, INetworkElement "
url="tcp://localhost:6000/NetworkElement. rem">
</wellknown>
</client>
</application>
</system.runtime. remoting>
</configuration>

Apr 13 '07 #2
More likely than not, your service is not aware of the type of the
client (which is understandable) . Events on objects that are exposed by
services are generally a bad idea.

What you want to do is create a proxy class which exposes the events you
want to fire. It should also implement an interface that has methods that
correspond to the event signatures. This proxy and the interface should
reside in a dll that is outside of the service and the client, but
referenced by both.

Then, you have a method on the service which you can use to register the
INTERFACE (not the actual type). Of course, the implementation of the proxy
derives from MarshalByRefObj ect.

Then, when you want to fire the event, the service calls the method on
the interface, which will then trigger the event in the proxy, which the
client will have subscribed to.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"erbilkonuk " <er********@gma il.comwrote in message
news:11******** **************@ y80g2000hsf.goo glegroups.com.. .
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
the Remoting Class that will be fired upon the private member value
change.

The problem is that I can not get the subscribed event fired. Do I
miss a point about Client Registration / Server Registration such
that
2 instances are created, 1 on Server Side, 1 on Client Side and the
event subscription is done on the wrong one? Please help :) Thanks in
advance...
[Remoting Class]
public class NetworkElement : MarshalByRefObj ect, INetworkElement
{
public event AlarmEventHandl er AlarmEvent;
private Boolean _ACFail;
public Boolean ACFail
{
get { return _ACFail; }
set
{
_ACFail = value;
OnAlarmsEvent(n ew AlarmEventArgs( 1));
}
}
protected void OnAlarmsEvent(A larmEventArgs arg)
{
if (AlarmEvent != null) AlarmEvent(this , arg);
}
public void AddAlarmEvent(A larmEventHandle r handler)
{
AlarmEvent += handler;
}
}
[Interface for Remoting Class]
public delegate void AlarmEventHandl er(object sender,
AlarmEventArgs arg);
[Serializable]
public class AlarmEventArgs : EventArgs
{
private Int32 _AlarmType;
public Int32 AlarmType
{
get { return _AlarmType; }
}
public AlarmEventArgs( Int32 Type)
{
_AlarmType = Type;
}
}
public interface INetworkElement
{
void AddAlarmEvent(A larmEventHandle r handler);
}
[The Remoting Client]
public class Client : MarshalByRefObj ect
{
public void SubscribeToAlar mEvent()
{
RemotingConfigu ration.Configur e("Client.exe.c onfig");
WellKnownClient TypeEntry[] entry =
RemotingConfigu ration.GetRegis teredWellKnownC lientTypes();
INetworkElement ine =
(INetworkElemen t)Activator.Get Object(entry[0].ObjectType,
entry[0].ObjectUrl);
ine.AddAlarmEve nt(new
AlarmEventHandl er(ClientEventH andler));
AlarmType = -1;
}
public void ClientEventHand ler(object sender, AlarmEventArgs
arg)
{
AlarmType = arg.AlarmType;
}
}
config files are :
[Server.exe.conf ig]
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.runtime .remoting>
<application>
<channels>
<channel port="6000" displayName="Se rverChannel" ref="tcp">
<serverProvider s>
<formatter ref="binary" typeFilterLevel ="Full"</
formatter>
</serverProviders >
<clientProvider s>
<formatter ref="binary"></formatter>
</clientProviders >
</channel>
</channels>
<service>
<wellknown type="NetworkE. NetworkElement, NetworkElement"
objectUri="Netw orkElement.rem" mode="Singleton ">
</wellknown>
</service>
</application>
</system.runtime. remoting>
</configuration>
[Client.exe.conf ig]
<?xml version="1.0" encoding="utf-8" ?>
<configuratio n>
<system.runtime .remoting>
<application>
<channels>
<channel port="0" displayName="Cl ientChannel" ref="tcp">
<clientProvider s>
<formatter ref="binary"></formatter>
</clientProviders >
<serverProvider s>
<formatter ref="binary" typeFilterLevel ="Full"></
formatter>
</serverProviders >
</channel>
</channels>
<client>
<wellknown type="INetworkE .INetworkElemen t, INetworkElement "
url="tcp://localhost:6000/NetworkElement. rem">
</wellknown>
</client>
</application>
</system.runtime. remoting>
</configuration>

Apr 13 '07 #3

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

Similar topics

21
9908
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
2
1906
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.
15
5746
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...
5
2132
by: Mark Overstreet | last post by:
I am writing an app that needs to contain an object model that allows it to be controlled similiar to something like Word. However, I am writing this in C# and all managed code. I know that I can use remoting to talk to the UI components but I need an example of how to create an event when something happens on the UI (e.g. text box receives focus) and fire that via my object model back to any remote client. I also need the ability to...
3
2086
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.?
9
2100
by: Nak | last post by:
Hi there, I have been messing around with remoting in an attempt to create a "shared application" as mentioned in another thread by that name. I have created a singleton object just like the example in the 101 VB.NET examples. It works great, only 1 instance ever gets created and is shared by each client. I have a few questions though, * Can the singleton contain events? In such a way that when the
3
1505
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...
13
3928
by: dmeglio | last post by:
Hello, I'm aware that when an EventHandler is created, it creates a reference to the object, therefore preventing GCing. Therefore, I've been implementing IDisposable in my controls to cleanup the mess (not a fun thing to retrofit). Anyway, my question is regarding this issue. When I create controls, the .NET IDE automatically registers events for me (the "Component
6
1881
by: tshad | last post by:
I was looking at a page that showed how to set up a custom event and it seems to work ok. But I am not sure how I would use it. How would I subscribe to it. There is actual action (such as pressing a button or changing text in a textbox). It gets set up and on the user control on my web page I can see the event from intellisense. So it seems to be set up, but I am trying to get an easy example of how I would now use this event. ...
0
8752
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
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9179
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
9116
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
8099
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 project—planning, coding, testing, and deployment—without 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
6702
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...
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.