473,396 Members | 1,810 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 - How to raise an event on a MarshalByRef Object in C#

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?
Nov 15 '05 #1
1 10488
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**********@gmx.net> wrote in message news:%2****************@TK2MSFTNGP09.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 : MarshalByRefObject
{
private Int32 current;
private Int32 total;

public event PrepareProgressHandler PrepareProgress;

//this is a Zip Control event handler
protected void OnZipProgress(DartZip.ZipStatusConstants constants,DartZip.File file,
Int32 x,Int32 fileBytes,Int32 totalBytes)
{
current=totalBytes;
total=file.Size;
try
{
(new Thread(new ThreadStart(OnPrepareProgress))).Start();
}
catch
{
log.WriteLine("OnZipProgress() - Cannot start a new thread");
}
}

protected virtual void OnPrepareProgress()
{
try
{
if (PrepareProgress!=null)
{
PrepareProgress(this,new PrepareProgressArgs(current,total));
}
}
catch
{
log.WriteLine("OnPrepareProgress - Cannot raise the event");
}
}

}

public class PrepareProgressArgs : EventArgs
{
private Int64 _current;
private Int64 _total;

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

public PrepareProgressArgs(Int64 current,Int64 total)
{
_current=current;
_total=total;
}
}

public delegate void PrepareProgressHandler(Object source,PrepareProgressArgs args);


//
//on client side
//

srv=(RemotingServer)Activator.GetObject(typeof(Rem otingServer),Settings..ServerName);
srv.PrepareProgress+=new Remoting.PrepareProgressHandler(srv_PrepareProgres s);

public void srv_PrepareProgress(Object sender,PrepareProgressArgs args)
{
pbrMain.Maximum=(Int32)args.Total;
pbrMain.Value=(Int32)args.Current;
Application.DoEvents();
}
"Anders Forsgren" <an*************@nospam.csce.se> wrote in message news:%2****************@TK2MSFTNGP10.phx.gbl...
On the server side (marshalByRef side) just raise the event in a new thread.


Server :
public event EventHandler MyServerEvent

private void RaiseServerEvent()

{

new Thread( new ThreadStart(DoMyServerEvent).Start();

}

public void DoMyServerEvent()

{

if (MyServerEvent != null)

MyServerEvent(this, 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**********@gmx.net> skrev i meddelandet
news:uI**************@tk2msftngp13.phx.gbl...
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?


Nov 15 '05 #2

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

Similar topics

1
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...
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...
5
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...
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...
1
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...
9
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...
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...
4
by: Rich | last post by:
Can anyone suggest a good (current) tutorial on how to do basic remoting with C# (2005 express edition)?
8
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
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.