start populating the new System.Web.Configuration_2.0 dir
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Channels / ChannelServices.cs
index f2f21baf53ee8db9254e81e0cd002a435d095839..e2ab7935e9c8c14070052e930f16ade2fa575782 100644 (file)
@@ -144,12 +144,15 @@ namespace System.Runtime.Remoting.Channels
                        get {
                                lock (registeredChannels.SyncRoot)
                                {
-                                       IChannel[] channels = new IChannel[registeredChannels.Count];
-       
-                                       for (int i = 0; i < registeredChannels.Count; i++)
-                                               channels[i] = (IChannel) registeredChannels[i];
-       
-                                       return channels;
+                                       ArrayList list = new ArrayList ();
+                                       
+                                       for (int i = 0; i < registeredChannels.Count; i++) {
+                                               IChannel ch = (IChannel) registeredChannels[i];
+                                               if (ch is CrossAppDomainChannel) continue;
+                                               list.Add (ch);
+                                       }
+
+                                       return (IChannel[]) list.ToArray (typeof(IChannel));
                                }
                        }
                }
@@ -428,14 +431,19 @@ namespace System.Runtime.Remoting.Channels
                                
                        lock (registeredChannels.SyncRoot)
                        {
-                               if (!registeredChannels.Contains ((object) chnl))
-                                       throw new RemotingException ();
-       
-                               registeredChannels.Remove ((object) chnl);
+                               for (int n=0; n<registeredChannels.Count; n++) 
+                               {
+                                       if (registeredChannels [n] == (object)chnl) {
+                                               registeredChannels.RemoveAt (n);
+                                               IChannelReceiver chnlReceiver = chnl as IChannelReceiver;
+                                               if(chnlReceiver != null)
+                                                       chnlReceiver.StopListening(null);
+                                               return;
+                                       }
+                               }
+                               
+                               throw new RemotingException ("Channel not registered");
        
-                               IChannelReceiver chnlReceiver = chnl as IChannelReceiver;
-                               if(chnlReceiver != null)
-                                       chnlReceiver.StopListening(null);
                        }
                }