471,313 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,313 software developers and data experts.

writing a service that broadcasts events to its controllers and isremotely callable

hi,

I know its possible to create a service by Inheriting from ServiceBase
and
controlling it from ServiceController.

BUT, how do I have the service broadcast an event to the service
controllers, _and_ how do I control the service across a network/or
from
networked computers.

I know this is probably possible with WCF, or .NET remoting, but is it
possible with plain .NET??

Could someone tell me how its possible in each technology and which
would be
the simplest to implement.

I'm trying to write a data service that serves and receives
data[represented
by objects] and should broadcast a notification when the data has been
updated.

Thanks so much
Sep 1 '08 #1
6 1093
giddy wrote:
hi,

I know its possible to create a service by Inheriting from ServiceBase
and
controlling it from ServiceController.

BUT, how do I have the service broadcast an event to the service
controllers, _and_ how do I control the service across a network/or
from
networked computers.

I know this is probably possible with WCF, or .NET remoting, but is it
possible with plain .NET??

Could someone tell me how its possible in each technology and which
would be
the simplest to implement.

I'm trying to write a data service that serves and receives
data[represented
by objects] and should broadcast a notification when the data has been
updated.

Thanks so much
You can do it via direct socket connections.
If you need to "discover" your server from a client you can do a UDP
broadcast where your server would have to respond and then initiate a
direct connection.

JB

-- Posted on news://freenews.netfront.net - Complaints to ne**@netfront.net --
Sep 1 '08 #2
Yea I know I could do it that way, but I was hoping to learn a little
about distributed apps by trying this with remoting or WCF both of
which I know nothing about.

I just managed to learn how to call an object over a network with the
remoting classes but I still havn't managed to figure out a way to
control/call an instance of a class over a network.
So could anyone tell me how to accomplish this with remoting or WCF.

Thanks so much
Gideon
Sep 1 '08 #3
"giddy" <gi*******@gmail.comwrote in message
news:a0**********************************@v13g2000 pro.googlegroups.com...
I know its possible to create a service by Inheriting from ServiceBase
and
controlling it from ServiceController.

BUT, how do I have the service broadcast an event to the service
controllers, _and_ how do I control the service across a network/or
from
networked computers.

I know this is probably possible with WCF, or .NET remoting, but is it
possible with plain .NET??
It's not clear what you mean by "plain .NET" - there's no such thing as far
as RPC is concerned. You can, of course, do it using WCF or .NET Remoting,
by hosting the corresponding listener thread inside your service process.
Could someone tell me how its possible in each technology and which
would be the simplest to implement.
For details on making your application a WCF or .NET Remoting service host,
see the two following MSDN articles:

http://msdn.microsoft.com/en-us/library/ms730935.aspx
http://msdn.microsoft.com/en-us/library/ecc85927.aspx

They are fully applicable to any type of application, including a Windows
service.

Sep 1 '08 #4
hi,

You will have to excuse my illeteracy with remoting I've bee
researching a LOT today and I found out about things like
RemotingConfiguration . RegisterWellKnownServiceType.

There is one problem with it, how do I allow an *instance* of an
object to be callable across processes?

Something like:

App2:
TextBox txtBox1;

TcpServerChannel channel = new TcpServerChannel(9988);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType (typeof(TextBox),
"TextBox", WellKnownObjectMode.SingleCall);//***can't i say txtBox1??
***

App2:
ChannelServices.RegisterChannel(new TcpChannel(),false);
TextBox t = (TextBox)Activator.GetObject(typeof(TextBox), "tcp://
localhost:9988/TextBox");
t.ForeColor = Color.Blue;
//Doesn't work!!?

Thanks so much

Sep 1 '08 #5

"giddy" <gi*******@gmail.comwrote in message
news:54**********************************@q26g2000 prq.googlegroups.com...
hi,

You will have to excuse my illeteracy with remoting I've bee
researching a LOT today and I found out about things like
RemotingConfiguration . RegisterWellKnownServiceType.

There is one problem with it, how do I allow an *instance* of an
object to be callable across processes?
You provide a factory as a well-known type that exposes the rest of the
objects in your application via properties and methods such as GetTextBox().
On the client, you obtain instance of that type, and then call its methods
to get proxies for those objects.

One thing, though. If you're doing remote calls over the network, I would
strongly advise to avoid traditional instance-centric object-oriented
approach in the remoting layer, and implement a stateless remote facade
instead. There are numerous reasons to do so, having to do with performance
as well as reliability, and rather than going into detail here, I'll just
refer you to the description of the remote facade pattern:

http://martinfowler.com/eaaCatalog/remoteFacade.html
http://martinfowler.com/eaaCatalog/d...ferObject.html

In this case, you can stick to using well-known types and SingleCall. For
..NET remoting, this also avoids lifetime management issues, which can get
messy with large object graphs.
Sep 1 '08 #6
hi,

Thanks so much for your reply. The facade finally makes more sense to
me now!!

I got exactly what I was looking for from this article though:
http://www.codeproject.com/KB/IP/remotinggui.aspx

He uses RemotingServices.Marshal() whichallows one to register an
*instance*.
I want to bother you with just one more thing.

On the server:

TcpChannel channel = new TcpChannel(9988);
ChannelServices.RegisterChannel(channel,false);
RemotingServices.Marshal(textBox1, "textBox");

And on the client:
ChannelServices.RegisterChannel(new TcpChannel(), false);
t = (TextBox)Activator.GetObject(typeof(TextBox), "tcp://localhost:
9988/textBox");
//t.TextChanged += new EventHandler(t_TextChanged); //works fine
untill i add THIS line.

Tells me:
Type System.DelegateSerializationHolder and the types derived from it
(such as System.DelegateSerializationHolder) are not permitted to be
deserialized at this security level.

I searched online and tried changing some filter setting to full
through config files, doesn't work, and I tried it with code I get a
TargetInvocationException, I'm probably doing something silly, could
you please help!?

Thanks so much

Gideon
Sep 2 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Marian Aldenhövel | last post: by
23 posts views Thread by Adam Clauss | last post: by
reply views Thread by Gianmaria Iaculo - NVENTA | last post: by
reply views Thread by rosydwin | last post: by

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.