[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

Callback delegate fails on Remoting

Duy Le

9/30/2004 7:49:00 PM

I have a singleton remote object that has a call back event/delegate. It works fine when my client app calls the remote object and the event gets fired. The remote object is hosted by a windows service. The lifetime lease is set to infinite. However, if I close down my client app and start up again, it gets the data from db and loads up the remote object. When I fire the callback event, it bombs with "No connection available because the remote object refused it". It only errors on the callback event, not when getting the data from the remote object to fill in data on my client form. To resolve this problem, I have to restart the windows service. Then the entire cycle happens again. First time through, nothing happens. Close down my app and open it up again and the callback fails. The lease time set to infinite doesn't seem to matter when I removed it. Any ideas


---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/n...
3 Answers

Ken Kolda

9/30/2004 9:17:00 PM

0

The problem almost certainly is that your server still is holding onto a
delegate for the first client instance, which is no longer is. When you
trigger the event, it attempts to contact that client and an exception
occurs because the network connection fails. Subsequently, the event never
gets a chance to invoke the delegate on your second client since it the
first delegate caused an exception.

Here's an article that talks about remoting and events -- they pose extra
challenges you need to be aware of.

http://www.dotnetjunkies.com/Tutorial/BFB598D4-0CC8-4392-893D-30252E2...

Hope that helps -
Ken



"Duy Le" <duydle@-NOSPAM-safeco.com> wrote in message
news:u5WZNaypEHA.1576@TK2MSFTNGP12.phx.gbl...
> I have a singleton remote object that has a call back event/delegate. It
works fine when my client app calls the remote object and the event gets
fired. The remote object is hosted by a windows service. The lifetime
lease is set to infinite. However, if I close down my client app and start
up again, it gets the data from db and loads up the remote object. When I
fire the callback event, it bombs with "No connection available because the
remote object refused it". It only errors on the callback event, not when
getting the data from the remote object to fill in data on my client form.
To resolve this problem, I have to restart the windows service. Then the
entire cycle happens again. First time through, nothing happens. Close
down my app and open it up again and the callback fails. The lease time set
to infinite doesn't seem to matter when I removed it. Any ideas?
>
>
> ---
> Posted using Wimdows.net Newsgroups - http://www.wimdows.net/n...


neo [mvp outlook]

10/1/2004 3:47:00 PM

0

Is there any way I can remove the link or unsuscribe not valid clients?
I have a try catch on the event invocation on the server, if the server can
not raise the event, will log its fail, but i dont want the server to try
again with the same not valid client.

Thanks in advance.

"Ken Kolda" wrote:

> The problem almost certainly is that your server still is holding onto a
> delegate for the first client instance, which is no longer is. When you
> trigger the event, it attempts to contact that client and an exception
> occurs because the network connection fails. Subsequently, the event never
> gets a chance to invoke the delegate on your second client since it the
> first delegate caused an exception.
>
> Here's an article that talks about remoting and events -- they pose extra
> challenges you need to be aware of.
>
> http://www.dotnetjunkies.com/Tutorial/BFB598D4-0CC8-4392-893D-30252E2...
>
> Hope that helps -
> Ken
>
>
>
> "Duy Le" <duydle@-NOSPAM-safeco.com> wrote in message
> news:u5WZNaypEHA.1576@TK2MSFTNGP12.phx.gbl...
> > I have a singleton remote object that has a call back event/delegate. It
> works fine when my client app calls the remote object and the event gets
> fired. The remote object is hosted by a windows service. The lifetime
> lease is set to infinite. However, if I close down my client app and start
> up again, it gets the data from db and loads up the remote object. When I
> fire the callback event, it bombs with "No connection available because the
> remote object refused it". It only errors on the callback event, not when
> getting the data from the remote object to fill in data on my client form.
> To resolve this problem, I have to restart the windows service. Then the
> entire cycle happens again. First time through, nothing happens. Close
> down my app and open it up again and the callback fails. The lease time set
> to infinite doesn't seem to matter when I removed it. Any ideas?
> >
> >
> > ---
> > Posted using Wimdows.net Newsgroups - http://www.wimdows.net/n...
>
>
>

Ken Kolda

10/1/2004 4:09:00 PM

0

The article I sent demonstrates how to remove the dead client from the event
delegate. Look at the code exeample that demonstrates using
GetInvocationList() -- in the Catch block he removes the delegate from the
event so it won't be called in the future.

Ken


"Neo" <Neo@discussions.microsoft.com> wrote in message
news:C24EBF5D-CB62-4940-92D6-5B5A450FA98D@microsoft.com...
> Is there any way I can remove the link or unsuscribe not valid clients?
> I have a try catch on the event invocation on the server, if the server
can
> not raise the event, will log its fail, but i dont want the server to try
> again with the same not valid client.
>
> Thanks in advance.
>
> "Ken Kolda" wrote:
>
> > The problem almost certainly is that your server still is holding onto a
> > delegate for the first client instance, which is no longer is. When you
> > trigger the event, it attempts to contact that client and an exception
> > occurs because the network connection fails. Subsequently, the event
never
> > gets a chance to invoke the delegate on your second client since it the
> > first delegate caused an exception.
> >
> > Here's an article that talks about remoting and events -- they pose
extra
> > challenges you need to be aware of.
> >
> >
http://www.dotnetjunkies.com/Tutorial/BFB598D4-0CC8-4392-893D-30252E2...
> >
> > Hope that helps -
> > Ken
> >
> >
> >
> > "Duy Le" <duydle@-NOSPAM-safeco.com> wrote in message
> > news:u5WZNaypEHA.1576@TK2MSFTNGP12.phx.gbl...
> > > I have a singleton remote object that has a call back event/delegate.
It
> > works fine when my client app calls the remote object and the event gets
> > fired. The remote object is hosted by a windows service. The lifetime
> > lease is set to infinite. However, if I close down my client app and
start
> > up again, it gets the data from db and loads up the remote object. When
I
> > fire the callback event, it bombs with "No connection available because
the
> > remote object refused it". It only errors on the callback event, not
when
> > getting the data from the remote object to fill in data on my client
form.
> > To resolve this problem, I have to restart the windows service. Then
the
> > entire cycle happens again. First time through, nothing happens. Close
> > down my app and open it up again and the callback fails. The lease time
set
> > to infinite doesn't seem to matter when I removed it. Any ideas?
> > >
> > >
> > > ---
> > > Posted using Wimdows.net Newsgroups -
http://www.wimdows.net/n...
> >
> >
> >