Fix NRE in Win32 IpcChannel.StopListening() when no server started
authorNiklas Therning <niklas@therning.org>
Mon, 7 Nov 2016 14:00:05 +0000 (15:00 +0100)
committerNiklas Therning <niklas@therning.org>
Mon, 7 Nov 2016 14:00:05 +0000 (15:00 +0100)
This makes the System.Runtime.Remoting test suite fail in various places on
Windows due to the TestFixtureTearDown method in BaseCalls throwing an NRE.

mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/IpcChannel.cs

index 883ea72ebe25f4b079ae0a684e021cede538bda7..599edd8a8039f54801a5191592799319ee077632 100644 (file)
@@ -115,7 +115,8 @@ namespace System.Runtime.Remoting.Channels.Ipc.Win32
 
         public void StartListening(object data)
         {
-            serverChannel.StartListening(data);
+            if (serverChannel != null)
+                serverChannel.StartListening(data);
         }
 
         public object ChannelData
@@ -128,7 +129,8 @@ namespace System.Runtime.Remoting.Channels.Ipc.Win32
 
         public void StopListening(object data)
         {
-            serverChannel.StopListening(data);
+            if (serverChannel != null)
+                serverChannel.StopListening(data);
         }
 
         public string[] GetUrlsForUri(string objectURI)