internal static void StartListeningForRemoteRequests() { ActivationServices.Startup(); DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; if (remotingData.ActivatorListening) { return; } object configLock = remotingData.ConfigLock; bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(configLock, ref lockTaken); if (remotingData.ActivatorListening) { return; } RemotingServices.MarshalInternal((MarshalByRefObject)Thread.GetDomain().RemotingData.ActivationListener, "RemoteActivationService.rem", typeof(IActivator)); ((ServerIdentity)IdentityHolder.ResolveIdentity("RemoteActivationService.rem")).SetSingletonObjectMode(); remotingData.ActivatorListening = true; } finally { if (lockTaken) { Monitor.Exit(configLock); } } }
private static bool IsCurrentContextOK(RuntimeType serverType, object[] props, ref ConstructorCallMessage ctorCallMsg) { object[] array = ActivationServices.PeekActivationAttributes(serverType); if (array != null) { ActivationServices.PopActivationAttributes(serverType); } object[] array2 = new object[] { ActivationServices.GetGlobalAttribute() }; object[] contextAttributesForType = ActivationServices.GetContextAttributesForType(serverType); Context currentContext = Thread.CurrentContext; ctorCallMsg = new ConstructorCallMessage(array, array2, contextAttributesForType, serverType); ctorCallMsg.Activator = new ConstructionLevelActivator(); bool flag = ActivationServices.QueryAttributesIfContextOK(currentContext, ctorCallMsg, array2); if (flag) { flag = ActivationServices.QueryAttributesIfContextOK(currentContext, ctorCallMsg, array); if (flag) { flag = ActivationServices.QueryAttributesIfContextOK(currentContext, ctorCallMsg, contextAttributesForType); } } return(flag); }
private static bool IsCurrentContextOK(RuntimeType serverType, object[] props, ref ConstructorCallMessage ctorCallMsg) { object[] objArray1 = ActivationServices.PeekActivationAttributes((Type)serverType); if (objArray1 != null) { ActivationServices.PopActivationAttributes((Type)serverType); } object[] objArray2 = new object[1] { (object)ActivationServices.GetGlobalAttribute() }; object[] objArray3 = (object[])ActivationServices.GetContextAttributesForType((Type)serverType); Context currentContext = Thread.CurrentContext; ctorCallMsg = new ConstructorCallMessage(objArray1, objArray2, objArray3, serverType); ctorCallMsg.Activator = (IActivator) new ConstructionLevelActivator(); bool flag = ActivationServices.QueryAttributesIfContextOK(currentContext, (IConstructionCallMessage)ctorCallMsg, objArray2); if (flag) { flag = ActivationServices.QueryAttributesIfContextOK(currentContext, (IConstructionCallMessage)ctorCallMsg, objArray1); if (flag) { flag = ActivationServices.QueryAttributesIfContextOK(currentContext, (IConstructionCallMessage)ctorCallMsg, objArray3); } } return(flag); }
internal static void StartListeningForRemoteRequests() { ActivationServices.Startup(); DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; if (!remotingData.ActivatorListening) { object configLock = remotingData.ConfigLock; bool flag = false; RuntimeHelpers.PrepareConstrainedRegions(); try { Monitor.Enter(configLock, ref flag); if (!remotingData.ActivatorListening) { RemotingServices.MarshalInternal(Thread.GetDomain().RemotingData.ActivationListener, "RemoteActivationService.rem", typeof(IActivator)); ServerIdentity serverIdentity = (ServerIdentity)IdentityHolder.ResolveIdentity("RemoteActivationService.rem"); serverIdentity.SetSingletonObjectMode(); remotingData.ActivatorListening = true; } } finally { if (flag) { Monitor.Exit(configLock); } } } }
internal static IConstructionReturnMessage Activate(RemotingProxy remProxy, IConstructionCallMessage ctorMsg) { IConstructionReturnMessage constructionReturnMessage; if (((ConstructorCallMessage)ctorMsg).ActivateInContext) { constructionReturnMessage = ctorMsg.Activator.Activate(ctorMsg); if (constructionReturnMessage.Exception != null) { throw constructionReturnMessage.Exception; } } else { ActivationServices.GetPropertiesFromAttributes(ctorMsg, ctorMsg.CallSiteActivationAttributes); ActivationServices.GetPropertiesFromAttributes(ctorMsg, ((ConstructorCallMessage)ctorMsg).GetWOMAttributes()); ActivationServices.GetPropertiesFromAttributes(ctorMsg, ((ConstructorCallMessage)ctorMsg).GetTypeAttributes()); IMessageSink clientContextChain = Thread.CurrentContext.GetClientContextChain(); IMethodReturnMessage methodReturnMessage = (IMethodReturnMessage)clientContextChain.SyncProcessMessage(ctorMsg); constructionReturnMessage = (methodReturnMessage as IConstructionReturnMessage); if (methodReturnMessage == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_Failed")); } if (methodReturnMessage.Exception != null) { throw methodReturnMessage.Exception; } } return(constructionReturnMessage); }
internal static IConstructionReturnMessage DoServerContextActivation(IConstructionCallMessage reqMsg) { Exception e = null; Type activationType = reqMsg.ActivationType; object serverObj = ActivationServices.ActivateWithMessage(activationType, reqMsg, null, out e); return(ActivationServices.SetupConstructionReply(serverObj, reqMsg, e)); }
public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg) { IConstructionCallMessage constructionCallMessage = ctorMsg; IActivator nextActivator = constructionCallMessage.Activator.NextActivator; constructionCallMessage.Activator = nextActivator; return(ActivationServices.DoServerContextActivation(ctorMsg)); }
internal static ContextAttribute GetGlobalAttribute() { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; if (remotingData.LocalActivator == null) { ActivationServices.Startup(); } return((ContextAttribute)remotingData.LocalActivator); }
internal static IActivator GetActivator() { DomainSpecificRemotingData remotingData = Thread.GetDomain().RemotingData; if (remotingData.LocalActivator == null) { ActivationServices.Startup(); } return((IActivator)remotingData.LocalActivator); }
private static MarshalByRefObject CreateObjectForCom(RuntimeType serverType, object[] props, bool bNewObj) { if (ActivationServices.PeekActivationAttributes((Type)serverType) != null) { throw new NotSupportedException(Environment.GetResourceString("NotSupported_ActivForCom")); } ActivationServices.InitActivationServices(); ProxyAttribute proxyAttribute = ActivationServices.GetProxyAttribute((Type)serverType); return(!(proxyAttribute is ICustomFactory) ? (MarshalByRefObject)Activator.CreateInstance((Type)serverType, true) : ((ICustomFactory)proxyAttribute).CreateInstance((Type)serverType)); }
private static void InitActivationServices() { if (ActivationServices.activator == null) { ActivationServices.activator = ActivationServices.GetActivator(); if (ActivationServices.activator == null) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadInternalState_ActivationFailure"), Array.Empty <object>())); } } }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context context = null; if (isContextful) { context = new Context(); ArrayList arrayList = (ArrayList)reqMsg.ContextProperties; for (int i = 0; i < arrayList.Count; i++) { IContextProperty contextProperty = arrayList[i] as IContextProperty; if (contextProperty == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } RuntimeAssembly asm = (RuntimeAssembly)contextProperty.GetType().Assembly; ActivationServices.CheckForInfrastructurePermission(asm); if (context.GetProperty(contextProperty.Name) == null) { context.SetProperty(contextProperty); } } context.Freeze(); for (int j = 0; j < arrayList.Count; j++) { if (!((IContextProperty)arrayList[j]).IsNewContextOK(context)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate internalCrossContextDelegate = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[] { reqMsg }; IConstructionReturnMessage result; if (isContextful) { result = (Thread.CurrentThread.InternalCrossContextCallback(context, internalCrossContextDelegate, args) as IConstructionReturnMessage); } else { result = (internalCrossContextDelegate(args) as IConstructionReturnMessage); } return(result); }
public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg) { if ((ctorMsg == null) || RemotingServices.IsTransparentProxy(ctorMsg)) { throw new ArgumentNullException("ctorMsg"); } ctorMsg.Properties["Permission"] = "allowed"; if (!RemotingConfigHandler.IsActivationAllowed(ctorMsg.ActivationTypeName)) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Activation_PermissionDenied"), new object[] { ctorMsg.ActivationTypeName })); } if (ctorMsg.ActivationType == null) { throw new RemotingException(string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_BadType"), new object[] { ctorMsg.ActivationTypeName })); } return(ActivationServices.GetActivator().Activate(ctorMsg)); }
internal static void GetPropertiesFromAttributes(IConstructionCallMessage ctorMsg, object[] attributes) { if (attributes == null) { return; } for (int index = 0; index < attributes.Length; ++index) { IContextAttribute contextAttribute = attributes[index] as IContextAttribute; if (contextAttribute == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } ActivationServices.CheckForInfrastructurePermission((RuntimeAssembly)contextAttribute.GetType().Assembly); contextAttribute.GetPropertiesForNewContext(ctorMsg); } }
public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg) { if (ctorMsg == null) { throw new ArgumentNullException("ctorMsg"); } if (ctorMsg.Properties.Contains((object)"Remote")) { return(LocalActivator.DoRemoteActivation(ctorMsg)); } if (!ctorMsg.Properties.Contains((object)"Permission")) { return(ctorMsg.Activator.Activate(ctorMsg)); } Type activationType = ctorMsg.ActivationType; object[] activationAttributes = (object[])null; if (activationType.IsContextful) { IList contextProperties = ctorMsg.ContextProperties; if (contextProperties != null && contextProperties.Count > 0) { activationAttributes = new object[1] { (object)new RemotePropertyHolderAttribute(contextProperties) } } ; } RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(LocalActivator.GetMethodBase(ctorMsg)); object[] args = Message.CoerceArgs((IMethodMessage)ctorMsg, reflectionCachedData.Parameters); object serverObj = Activator.CreateInstance(activationType, args, activationAttributes); if (RemotingServices.IsClientProxy(serverObj)) { RedirectionProxy redirectionProxy = new RedirectionProxy((MarshalByRefObject)serverObj, activationType); // ISSUE: variable of the null type __Null local = null; Type RequestedType = activationType; RemotingServices.MarshalInternal((MarshalByRefObject)redirectionProxy, (string)local, RequestedType); serverObj = (object)redirectionProxy; } return(ActivationServices.SetupConstructionReply(serverObj, ctorMsg, (Exception)null)); }
public static IMessage Activate(RemotingProxy proxy, ConstructionCall ctorCall) { ctorCall.SourceProxy = proxy; IMessage message; if (Thread.CurrentContext.HasExitSinks && !ctorCall.IsContextOk) { message = Thread.CurrentContext.GetClientContextSinkChain().SyncProcessMessage(ctorCall); } else { message = ActivationServices.RemoteActivate(ctorCall); } if (message is IConstructionReturnMessage && ((IConstructionReturnMessage)message).Exception == null && proxy.ObjectIdentity == null) { Identity messageTargetIdentity = RemotingServices.GetMessageTargetIdentity(ctorCall); proxy.AttachIdentity(messageTargetIdentity); } return(message); }
public static IMessage CreateInstanceFromMessage(IConstructionCallMessage ctorCall) { object obj = ActivationServices.AllocateUninitializedClassInstance(ctorCall.ActivationType); ServerIdentity serverIdentity = (ServerIdentity)RemotingServices.GetMessageTargetIdentity(ctorCall); serverIdentity.AttachServerObject((MarshalByRefObject)obj, Thread.CurrentContext); ConstructionCall constructionCall = ctorCall as ConstructionCall; if (ctorCall.ActivationType.IsContextful && constructionCall != null && constructionCall.SourceProxy != null) { constructionCall.SourceProxy.AttachIdentity(serverIdentity); MarshalByRefObject target = (MarshalByRefObject)constructionCall.SourceProxy.GetTransparentProxy(); RemotingServices.InternalExecuteMessage(target, ctorCall); } else { ctorCall.MethodBase.Invoke(obj, ctorCall.Args); } return(new ConstructionResponse(obj, null, ctorCall)); }
private static MarshalByRefObject IsCurrentContextOK(RuntimeType serverType, object[] props, bool bNewObj) { ActivationServices.InitActivationServices(); ProxyAttribute proxyAttribute = ActivationServices.GetProxyAttribute((Type)serverType); MarshalByRefObject marshalByRefObject; if (proxyAttribute == ActivationServices.DefaultProxyAttribute) { marshalByRefObject = proxyAttribute.CreateInstanceInternal(serverType); } else { marshalByRefObject = proxyAttribute.CreateInstance((Type)serverType); if (marshalByRefObject != null && !RemotingServices.IsTransparentProxy((object)marshalByRefObject) && !serverType.IsAssignableFrom(marshalByRefObject.GetType())) { throw new RemotingException(string.Format((IFormatProvider)CultureInfo.CurrentCulture, Environment.GetResourceString("Remoting_Activation_BadObject"), (object)serverType)); } } return(marshalByRefObject); }
public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg) { if (ctorMsg == null) { throw new ArgumentNullException("ctorMsg"); } if (ctorMsg.Properties.Contains("Remote")) { return(LocalActivator.DoRemoteActivation(ctorMsg)); } if (ctorMsg.Properties.Contains("Permission")) { Type activationType = ctorMsg.ActivationType; object[] activationAttributes = null; if (activationType.IsContextful) { IList contextProperties = ctorMsg.ContextProperties; if (contextProperties != null && contextProperties.Count > 0) { RemotePropertyHolderAttribute remotePropertyHolderAttribute = new RemotePropertyHolderAttribute(contextProperties); activationAttributes = new object[] { remotePropertyHolderAttribute }; } } MethodBase methodBase = LocalActivator.GetMethodBase(ctorMsg); RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(methodBase); object[] args = Message.CoerceArgs(ctorMsg, reflectionCachedData.Parameters); object obj = Activator.CreateInstance(activationType, args, activationAttributes); if (RemotingServices.IsClientProxy(obj)) { RedirectionProxy redirectionProxy = new RedirectionProxy((MarshalByRefObject)obj, activationType); RemotingServices.MarshalInternal(redirectionProxy, null, activationType); obj = redirectionProxy; } return(ActivationServices.SetupConstructionReply(obj, ctorMsg, null)); } return(ctorMsg.Activator.Activate(ctorMsg)); }
internal static MarshalByRefObject CreateInstance(RuntimeType serverType) { ConstructorCallMessage ctorCallMsg = (ConstructorCallMessage)null; bool flag = ActivationServices.IsCurrentContextOK(serverType, (object[])null, ref ctorCallMsg); MarshalByRefObject marshalByRefObject; if (flag && !serverType.IsContextful) { marshalByRefObject = RemotingServices.AllocateUninitializedObject(serverType); } else { marshalByRefObject = (MarshalByRefObject)ActivationServices.ConnectIfNecessary((IConstructionCallMessage)ctorCallMsg); RemotingProxy remotingProxy; if (marshalByRefObject == null) { remotingProxy = new RemotingProxy((Type)serverType); marshalByRefObject = (MarshalByRefObject)remotingProxy.GetTransparentProxy(); } else { remotingProxy = (RemotingProxy)RemotingServices.GetRealProxy((object)marshalByRefObject); } remotingProxy.ConstructorMessage = ctorCallMsg; if (!flag) { ctorCallMsg.Activator = (IActivator) new ContextLevelActivator() { NextActivator = ctorCallMsg.Activator } } ; else { ctorCallMsg.ActivateInContext = true; } } return(marshalByRefObject); }
internal static IConstructionReturnMessage DoCrossContextActivation(IConstructionCallMessage reqMsg) { bool isContextful = reqMsg.ActivationType.IsContextful; Context context = (Context)null; if (isContextful) { context = new Context(); ArrayList arrayList = (ArrayList)reqMsg.ContextProperties; for (int index = 0; index < arrayList.Count; ++index) { IContextProperty prop = arrayList[index] as IContextProperty; if (prop == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } ActivationServices.CheckForInfrastructurePermission((RuntimeAssembly)prop.GetType().Assembly); if (context.GetProperty(prop.Name) == null) { context.SetProperty(prop); } } context.Freeze(); for (int index = 0; index < arrayList.Count; ++index) { if (!((IContextProperty)arrayList[index]).IsNewContextOK(context)) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_PropertyUnhappy")); } } } InternalCrossContextDelegate ftnToCall = new InternalCrossContextDelegate(ActivationServices.DoCrossContextActivationCallback); object[] args = new object[1] { (object)reqMsg }; return(!isContextful?ftnToCall(args) as IConstructionReturnMessage : Thread.CurrentThread.InternalCrossContextCallback(context, ftnToCall, args) as IConstructionReturnMessage); }
private static bool QueryAttributesIfContextOK(Context ctx, IConstructionCallMessage ctorMsg, object[] attributes) { bool flag = true; if (attributes != null) { for (int index = 0; index < attributes.Length; ++index) { IContextAttribute contextAttribute = attributes[index] as IContextAttribute; if (contextAttribute == null) { throw new RemotingException(Environment.GetResourceString("Remoting_Activation_BadAttribute")); } ActivationServices.CheckForInfrastructurePermission((RuntimeAssembly)contextAttribute.GetType().Assembly); flag = contextAttribute.IsContextOK(ctx, ctorMsg); if (!flag) { break; } } } return(flag); }
public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg) { ctorMsg.Activator = this.m_NextActivator; return(ActivationServices.GetActivator().Activate(ctorMsg)); }
public virtual IConstructionReturnMessage Activate(IConstructionCallMessage ctorMsg) { ctorMsg.Activator = ctorMsg.Activator.NextActivator; return(ActivationServices.DoCrossContextActivation(ctorMsg)); }
internal static void Initialize() { ActivationServices.GetActivator(); }
internal static IConstructionReturnMessage DoServerContextActivation(IConstructionCallMessage reqMsg) { Exception e = (Exception)null; return(ActivationServices.SetupConstructionReply(ActivationServices.ActivateWithMessage(reqMsg.ActivationType, (IMessage)reqMsg, (ServerIdentity)null, out e), reqMsg, e)); }