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

  • Thread starter Thread starter giddy
  • Start date Start date
G

giddy

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
 
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
 
giddy said:
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.
 
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
 
giddy said:
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/dataTransferObject.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.
 
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
 
Back
Top