Kaynağa Gözat

2005-05-18 Lluis Sanchez Gual <[email protected]>

	* BinaryServerFormatterSink.cs: Properly handle exceptions raised
	during serialization. Fixes bug #74950.


svn path=/trunk/mcs/; revision=44689
Lluis Sanchez 20 yıl önce
ebeveyn
işleme
8ea7557944

+ 18 - 8
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/BinaryServerFormatterSink.cs

@@ -140,17 +140,27 @@ namespace System.Runtime.Remoting.Channels {
 				responseHeaders = null;
 				responseStream = null;
 			}
-
+			
 			if (res == ServerProcessing.Complete)
 			{
-				responseStream = null;
-				responseHeaders = new TransportHeaders();
-
-				if (sinkStack != null) responseStream = sinkStack.GetResponseStream (responseMsg, responseHeaders);
-				if (responseStream == null) responseStream = new MemoryStream();
-
-				_binaryCore.Serializer.Serialize (responseStream, responseMsg);
+				for (int n=0; n<3; n++) {
+					responseStream = null;
+					responseHeaders = new TransportHeaders();
+
+					if (sinkStack != null) responseStream = sinkStack.GetResponseStream (responseMsg, responseHeaders);
+					if (responseStream == null) responseStream = new MemoryStream();
+
+					try {
+						_binaryCore.Serializer.Serialize (responseStream, responseMsg);
+						break;
+					} catch (Exception ex) {
+						if (n == 2) throw ex;
+						else responseMsg = new ReturnMessage (ex, (IMethodCallMessage)requestMsg);
+					}
+				}
+				
 				if (responseStream is MemoryStream) responseStream.Position = 0;
+				
 
 				sinkStack.Pop (this);
 			}

+ 5 - 0
mcs/class/System.Runtime.Remoting/System.Runtime.Remoting.Channels/ChangeLog

@@ -1,3 +1,8 @@
+2005-05-18  Lluis Sanchez Gual  <[email protected]>
+
+	* BinaryServerFormatterSink.cs: Properly handle exceptions raised
+	during serialization. Fixes bug #74950.
+
 2005-01-14  Lluis Sanchez Gual  <[email protected]>
 
 	* SoapMessageFormatter.cs, SoapServerFormatterSink.cs: Fixed warnings.