473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remoting - How to raise an event on a MarshalByRef Object in C#

I have a remoting object, derived from MarshalByRefCom ponent, that I
instantiate on the client side, with Activator.GetOb ject.
Can I receive events fired on the server, on the client?
How?
Nov 15 '05 #1
1 10505
This is the error that I get when trying to raise the event.

This remoting proxy has no channel sink which means either the server has no registered server channels that are listening, or this application has no suitable client channel to talk to the server.
"Dan Cimpoiesu" <da**********@g mx.net> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Thanks Anders

But I still can't manage to make it work.
Still nothing happens on client when I raise the event from server.

Here are some snippets of my code.

//
//on server side
//
public class RemotingServer : MarshalByRefObj ect
{
private Int32 current;
private Int32 total;

public event PrepareProgress Handler PrepareProgress ;

//this is a Zip Control event handler
protected void OnZipProgress(D artZip.ZipStatu sConstants constants,DartZ ip.File file,
Int32 x,Int32 fileBytes,Int32 totalBytes)
{
current=totalBy tes;
total=file.Size ;
try
{
(new Thread(new ThreadStart(OnP repareProgress) )).Start();
}
catch
{
log.WriteLine(" OnZipProgress() - Cannot start a new thread");
}
}

protected virtual void OnPrepareProgre ss()
{
try
{
if (PrepareProgres s!=null)
{
PrepareProgress (this,new PrepareProgress Args(current,to tal));
}
}
catch
{
log.WriteLine(" OnPrepareProgre ss - Cannot raise the event");
}
}

}

public class PrepareProgress Args : EventArgs
{
private Int64 _current;
private Int64 _total;

public Int64 Current
{
get {return _current;}
}
public Int64 Total
{
get {return _total;}
}

public PrepareProgress Args(Int64 current,Int64 total)
{
_current=curren t;
_total=total;
}
}

public delegate void PrepareProgress Handler(Object source,PrepareP rogressArgs args);


//
//on client side
//

srv=(RemotingSe rver)Activator. GetObject(typeo f(RemotingServe r),Settings..Se rverName);
srv.PrepareProg ress+=new Remoting.Prepar eProgressHandle r(srv_PreparePr ogress);

public void srv_PrepareProg ress(Object sender,PrepareP rogressArgs args)
{
pbrMain.Maximum =(Int32)args.To tal;
pbrMain.Value=( Int32)args.Curr ent;
Application.DoE vents();
}
"Anders Forsgren" <an************ *@nospam.csce.s e> wrote in message news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
On the server side (marshalByRef side) just raise the event in a new thread.


Server :
public event EventHandler MyServerEvent

private void RaiseServerEven t()

{

new Thread( new ThreadStart(DoM yServerEvent).S tart();

}

public void DoMyServerEvent ()

{

if (MyServerEvent != null)

MyServerEvent(t his, new EventArgs());

}


The client can subscribe to this event in the usual way. I Don't know if
there is a more elegant way of doing remote/multithreaded events, but this
works. Hope it helps.
/Anders



"Dan Cimpoiesu" <da**********@g mx.net> skrev i meddelandet
news:uI******** ******@tk2msftn gp13.phx.gbl...
I have a remoting object, derived from MarshalByRefCom ponent, that I
instantiate on the client side, with Activator.GetOb ject.
Can I receive events fired on the server, on the client?
How?


Nov 15 '05 #2

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

Similar topics

1
2278
by: Bruce M. Carroll | last post by:
I am doing some work a distributed application, which uses events and remoting to accomplish the signaling between applications. This all works. The problem I have (I think) is that since remoting/events essentially guarantees that you are working in a multi-threaded environment, the developer of the application that consumes these events, if they intend on using these events to update a UI, has to understand delegates and invokes....
15
5742
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
2130
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...
4
3110
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 (as demonstrated in the AddMessage()
1
1820
by: Bob | last post by:
Let's say I want a program running on one computer to interact in real time with a program running on another computer. With Remoting, I can use a client object to create or connect to a server object and access its methods. But the server object only "responds when asked". I don't see how it could "raise an event" to the client object, thereby facilitating a "two-way" conversation where either object could initiate a process on the...
9
2093
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
4
2255
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.”}
4
6631
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
8
3497
by: schaf | last post by:
Hi Ng! My application (version 1 a1) communicates with a service (version 1 s1). Now I would like to update the service and create a service version 2 (s2). The new function calls within s2 are implemented in a new interface, which derive from the old one to ensure that an old version of my application (a1) still works with s2. If i run my new version of the application a2 with s1 I get a InvalidCastException (Return argument has an...
0
8009
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
7939
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
8428
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...
0
8299
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
6753
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
5962
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
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
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
0
1285
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.