This is where things can get complicated, depending on your application
needs. If you are using remoting, it may be better to forget about using
events in the conventional sense. Instead, I would suggest designing the
system so clients call a "subscribe" method on the service. The service will
then maintain a list of subscribed clients, and when needed, sends a
"message" to the client. Problems may occur if for some reason, sending this
message fails (e.g. network problem, or client machine crashes, etc.) Then
server would need to handle exception and remove client from list. But what
if the client is still reachable, and the problem was temporary. Now they are
not receiveing the events? Probably a few solutions, one would be to have the
client send a mesasge to the server if it had not received a message for X
intervals.
Enough rambling though. If you are looking for specific remoting answers, I
would recommend you post a mesage on the
microsoft.public.dotnet.framework.remoting group, as Ken Kolda and Sam
Santiago generally give very good advice there on a lot of remoting queries.
HTH
Dan
[quoted text, click to view] "Trevor Braun" wrote:
> I've looked at the remoting stuff, and gotten a sample (remote DLL) working,
> but still not across applications.
>
> I'm lost as to how I can have the client application reference events in the
> server application. Do you know of any examples where I can see a server
> application raising an event in a client application?
>
> Thanks,
> Trevor Braun
>
> "Richard Grimes [MVP]" <read my sig> wrote in message
> news:eBXTm1r7EHA.2568@TK2MSFTNGP10.phx.gbl...
> > Trevor Braun wrote:
> >> I have a windows service that generates events when it finds certain
> >> database information. That is, the service runs, and on a timer
> >> event, it checks a few database tables for new records. If the new
> >> records have been created, it generates the NewRecord event.
> >>
> >> I would like to have a client application subscribe to the events
> >
> > Stop there. Client *application*. Windows *service*. You have two
> > processes.
> >
> >> generated by the windows service, but when I attempt to use the
> >> service as a reference in my VS.NET project, I get an error that says
> >> I can only reference DLL's.
> >
> > That's because the memory address for your event handler is only valid in
> > the current process. Your service is another process.
> >
> >> Can anyone recommend a way for me to "accomplish my mission"?
> >
> > You have to use .NET remoting. .NET remoting is used to marshal calls
> > between two AppDomains. Those AppDomains could be in the same process,
> > could be in two different processes on the same machine (your situation)
> > or in two different processes on two different machines.
> >
> > Note that if the service is running as LOCALSYSTEM it won't be able to
> > raise an even to a client on another machine because LOCALSYSTEM does not
> > network privileges.
> >
> > It depends on what sort of data you pass in the event, if its simple data
> > then I would favour use a lightweight solution like a socket to pass the
> > data to the client. (If you have some database rowobject, you just need to
> > serialize the object, send it through the socket and deserialize it on the
> > client side.)
> >
> > Richard
> > --
> >
www.richardgrimes.com > > my email evpuneqt@zicf.bet is encrypted with ROT13 (
www.rot13.org)
> >
> >
>
>