diff options
Diffstat (limited to 'mcs/class/corlib/System.Runtime.Remoting')
5 files changed, 71 insertions, 17 deletions
diff --git a/mcs/class/corlib/System.Runtime.Remoting/ChangeLog b/mcs/class/corlib/System.Runtime.Remoting/ChangeLog index 1fc62be042d..14aa52173f9 100755 --- a/mcs/class/corlib/System.Runtime.Remoting/ChangeLog +++ b/mcs/class/corlib/System.Runtime.Remoting/ChangeLog @@ -1,3 +1,21 @@ +2004-07-22 Lluis Sanchez Gual <lluis@novell.com> + + * ObjRef.cs: Fixed type check in in ObjRef constructor. The requested class + must be the object class or a base class. This fixes bug #61249. + +2004-07-22 Lluis Sanchez Gual <lluis@novell.com> + + * RemotingServices.cs: Changed GetMethodBaseFromMethodMessage so its code + can be reused internally. Also fixed bug when gettting a method from an + interface. + +2004-07-02 Lluis Sanchez Gual <lluis@ximian.com> + + * RemotingConfiguration.cs: Avoid adding "id" and "type" as custom + properties of providers. This fixes bug #60934. + * ServerIdentity.cs, RemotingServices.cs: When disposing an identity, detach + the identity from the object, so it can be safely marshalled again. + 2004-06-15 Gert Driesen <drieseng@users.sourceforge.net> * RemotingTimeoutException.cs: added missing serialization ctor diff --git a/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs b/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs index 90db146c267..30234367827 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/ObjRef.cs @@ -92,7 +92,7 @@ namespace System.Runtime.Remoting { uri = RemotingServices.GetObjectUri(mbr); typeInfo = new TypeInfo(type); - if (!typeInfo.CanCastTo(mbr.GetType(), mbr)) + if (!type.IsAssignableFrom (mbr.GetType())) throw new RemotingException ("The server object type cannot be cast to the requested type " + type.FullName + "."); UpdateChannelInfo(); diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs index 204bc6b4368..2cbe62dff51 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingConfiguration.cs @@ -721,9 +721,9 @@ namespace System.Runtime.Remoting if (at == "id" && isTemplate) prov.Id = val; - if (at == "type") + else if (at == "type") prov.Type = val; - if (at == "ref" && !isTemplate) + else if (at == "ref" && !isTemplate) prov.Ref = val; else prov.CustomProperties.Add (at, val); diff --git a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs index aa694cbb3b6..6d4b810ed13 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs @@ -57,6 +57,7 @@ namespace System.Runtime.Remoting internal static string app_id; static int next_id = 1; + static readonly BindingFlags methodBindings = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; static RemotingServices () { @@ -159,8 +160,10 @@ namespace System.Runtime.Remoting else throw new ArgumentException ("The obj parameter is a proxy."); } - else + else { identity = obj.ObjectIdentity; + obj.ObjectIdentity = null; + } if (identity == null || !identity.IsConnected) return false; @@ -288,22 +291,49 @@ namespace System.Runtime.Remoting Type type = Type.GetType (msg.TypeName); if (type == null) throw new RemotingException ("Type '" + msg.TypeName + "' not found."); - - BindingFlags bflags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; + + return GetMethodBaseFromName (type, msg.MethodName, (Type[]) msg.MethodSignature); + } + + internal static MethodBase GetMethodBaseFromName (Type type, string methodName, Type[] signature) + { + if (type.IsInterface) { + return FindInterfaceMethod (type, methodName, signature); + } + else { + MethodBase method = null; + if (signature == null) + method = type.GetMethod (methodName, methodBindings); + else + method = type.GetMethod (methodName, methodBindings, null, (Type[]) signature, null); + + if (method != null) + return method; + + if (signature == null) + return type.GetConstructor (methodBindings, null, Type.EmptyTypes, null); + else + return type.GetConstructor (methodBindings, null, signature, null); + } + } + + static MethodBase FindInterfaceMethod (Type type, string methodName, Type[] signature) + { + MethodBase method = null; - MethodBase method; - if (msg.MethodSignature == null) - method = type.GetMethod (msg.MethodName, bflags); + if (signature == null) + method = type.GetMethod (methodName, methodBindings); else - method = type.GetMethod (msg.MethodName, bflags, null, (Type[]) msg.MethodSignature, null); + method = type.GetMethod (methodName, methodBindings, null, signature, null); + + if (method != null) return method; - if (method != null) - return method; + foreach (Type t in type.GetInterfaces ()) { + method = FindInterfaceMethod (t, methodName, signature); + if (method != null) return method; + } - if (msg.MethodSignature == null) - return type.GetConstructor (bflags, null, Type.EmptyTypes, null); - else - return type.GetConstructor (bflags, null, (Type[]) msg.MethodSignature, null); + return null; } public static void GetObjectData(object obj, SerializationInfo info, StreamingContext context) diff --git a/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs b/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs index f5ed96a066b..72c025121d0 100644 --- a/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs +++ b/mcs/class/corlib/System.Runtime.Remoting/ServerIdentity.cs @@ -136,7 +136,13 @@ namespace System.Runtime.Remoting protected void DisposeServerObject() { - _serverObject = null; + // Detach identity from server object to avoid problems if the + // object is marshalled again. + + if (_serverObject != null) { + _serverObject.ObjectIdentity = null; + _serverObject = null; + } } } |