[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Remote events in Whidbey Beta1

Oli

9/29/2004 3:37:00 PM

Hi,

I have a simple application based on the many examples for setting up
multiple clients to subscribe to events on a remote singleton.

So the problem occurs when coding for dead delegates. If a client has
subscribed to the event on the singleton, then subsequently crashed,
then an invalid delegate is left in the event's invocation list.

I've seen many posts that account for this by iterating through the
invocation list of the event and running each delegate with a try /
catch. If there is an exception running the delegate, then it is
removed from the event's invocation list.

I am getting a runtime exception when removing the delegate ONLY in
Whidbey beta 1 - the VS.NET 2003 equivalent works fine. Currently
looking for a workaround.

The exception is SocketException... No connection could be made because
the target machine actively refused it.

Code...

DataChangedEventHandler currentDelegate = null;

foreach (Delegate item in myevent.GetInvocationList())
{
try
{
currentDelegate = (DataChangedEventHandler)item;
currentDelegate(this, e);
}
catch
{
myevent -= currentDelegate; *** blows up here
}
}

Any ideas about how to proceed? For some reason it is trying to contact
the remote object when I remove the delegate.

Thanks,
Oli