.NET Forum / .NET Framework / Distributed Applications / March 2008
System.Delegate.Remove fialed on remote delegates
|
|
Thread rating:  |
Bart - 05 Feb 2008 10:36 GMT Hi,
I have remote delegates, but when the remote client is not avialable anymore (crashed for example), I can't remove the delegate from the inivocation list on the server side. When I call System.Delegate.Remove I got the error message:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the con nected party did not properly respond after a period of time, or established connection failed because connected host ha s failed to respond 192.168.0.223:4674 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddr ess& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) --- End of inner exception stack trace ---
How can I remove a remote delegate if the remote object doesn't exists anymore?
Thanks Bart
Walter Wang [MSFT] - 06 Feb 2008 02:45 GMT Hi Bart,
Based on my understanding, System.Delegate.Remove will not raise the exception; invoking a method on a dead client will. In which case you should catch the exception and calls System.Delegate.Remove on it.
I hope I haven't misunderstood anything.
Regards, Walter Wang (wawang@online.microsoft.com, remove 'online.') Microsoft Online Community Support
================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Bart - 19 Feb 2008 13:31 GMT You are right. I was throwing the original exception again. Now the System.Delegate.Remove does not throw any exeption but the delegate is not removed.
What could be wrong?
This is my code: public static void UpdateRemoteClient(object sp )
{ SubParameters par = (SubParameters)sp; try { par.subm.Invoke(null, par.e); } catch (Exception ex) { try { //par.Submission -= new SubmissionEventHandler(par.subm); System.Delegate.Remove(par.Submission, par.subm); } catch (Exception ex1) { log.Error( ex1); } } }
> Hi Bart, > [quoted text clipped - 14 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Walter Wang [MSFT] - 20 Feb 2008 07:34 GMT Hi Bart,
If you check the documentation of System.Delegate.Remove, you will find that it returns a new delegate with an invocation list formed by taking the invocation list of sourceand removing the last occurrence of the invocation list of value.
Therefore you need to set its return value to the first parameter:
par.Submission = System.Delegate.Remove(par.Submission, par.subm);
Hope this helps.
Regards, Walter Wang (wawang@online.microsoft.com, remove 'online.') Microsoft Online Community Support
================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Jialiang Ge [MSFT] - 28 Feb 2008 04:06 GMT Hello Bart,
Would you mind letting me know the result of the suggestions from Walter? If you need further assistance, feel free to let me know.
Have a great day!
Regards, Jialiang Ge (jialge@online.microsoft.com, remove 'online.') Microsoft Online Community Support
================================================= When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================= This posting is provided "AS IS" with no warranties, and confers no rights.
Bart - 28 Feb 2008 09:46 GMT Hi Jialiang,
Yes, indeed, thanks
Bart
> Hello Bart, > [quoted text clipped - 12 lines] > ================================================= > This posting is provided "AS IS" with no warranties, and confers no rights. Bart - 07 Mar 2008 11:22 GMT Hi Jialiang,
I cannot find the the name or ip address of the client in the remote objects. Do you know where I can find in the objects returned by the getinvocationlist where I can find the client identification?
Thanks Bart
> Hello Bart, > [quoted text clipped - 12 lines] > ================================================= > This posting is provided "AS IS" with no warranties, and confers no rights. Jialiang Ge [MSFT] - 10 Mar 2008 05:33 GMT Hello Brat,
I find this entry of maillist online: "Retrieving IP Address using Remoting" http://www.mail-archive.com/advanced-dotnet@discuss.develop.com/msg05704.htm l In the post, it returns the clients information of the Delegate collection returned by GetInvocationList(). Please have a try and let me know if it works for your question.
Regards, Jialiang Ge (jialge@online.microsoft.com, remove 'online.') Microsoft Online Community Support
================================================= Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights. =================================================
Jialiang Ge [MSFT] - 14 Mar 2008 06:58 GMT Hello Bart,
Since I haven't seen your reply after I last posted mine, I am writing to check the status of this post. Would you mind letting me know the result of the suggestions? Please feel free to let me know if there's anything else I can help. Thanks.
Best regards, Jialiang Ge (jialge@online.microsoft.com, remove 'online.') Microsoft Online Community Support
================================================= Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights. =================================================
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|