2008-01-15 Stephane Delcroix <sdelcroix@novell.com>
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Messaging / ReturnMessage.cs
index 2b75559217385953215298fad26d4a8dbad2013a..aee39f5bb81103129491a363a4e1641fd44a3d56 100644 (file)
@@ -37,6 +37,9 @@ using System.IO;
 
 namespace System.Runtime.Remoting.Messaging 
 {
+#if NET_2_0
+       [System.Runtime.InteropServices.ComVisible (true)]
+#endif
        public class ReturnMessage : IMethodReturnMessage, IMethodMessage, IMessage, IInternalMessage 
        {
                object[] _outArgs;
@@ -64,8 +67,10 @@ namespace System.Runtime.Remoting.Messaging
                        _args = outArgs;
                        _outArgsCount = outArgCount;
                        _callCtx = callCtx;
-                       _uri = request.Uri;
-                       _methodBase = request.MethodBase;
+                       if (request != null) {
+                               _uri = request.Uri;
+                               _methodBase = request.MethodBase;
+                       }
                        if (_args == null) _args = new object [outArgCount];
                }
 
@@ -73,8 +78,10 @@ namespace System.Runtime.Remoting.Messaging
                {
                        _exception = exc;
                        
-                       if (request != null)
+                       if (request != null) {
                                _methodBase = request.MethodBase;
+                               _callCtx = request.LogicalCallContext;
+                       }
                        _args = new object[0];  // .NET does this
                }
                
@@ -92,12 +99,15 @@ namespace System.Runtime.Remoting.Messaging
                
                public bool HasVarArgs {
                        get {
-                               return (MethodBase.CallingConvention | CallingConventions.VarArgs) != 0;
+                               if (_methodBase == null) return false;
+                               else return (_methodBase.CallingConvention | CallingConventions.VarArgs) != 0;
                        }
                }
 
                public LogicalCallContext LogicalCallContext {
                        get {
+                               if (_callCtx == null)
+                                       _callCtx = new LogicalCallContext ();
                                return _callCtx;
                        }
                }
@@ -156,6 +166,11 @@ namespace System.Runtime.Remoting.Messaging
                        }
                }
 
+               string IInternalMessage.Uri {
+                       get { return Uri; }
+                       set { Uri = value; }
+               }
+
                public object GetArg (int arg_num)
                {
                        return _args [arg_num];
@@ -214,6 +229,7 @@ namespace System.Runtime.Remoting.Messaging
                        set { _targetIdentity = value; }
                }
 
+#if !NET_2_0
                public override string ToString ()
                {
                        string s = TypeName.Split(',')[0] + "." + MethodName + " (";
@@ -235,5 +251,6 @@ namespace System.Runtime.Remoting.Messaging
                        }
                        return s;
                }
+#endif
        }
 }