{
internal class ActivationServices
{
- static IActivator _constructionActivator = new ConstructionLevelActivator ();
+ static IActivator _constructionActivator;
+
+ static IActivator ConstructionActivator {
+ get {
+ if (_constructionActivator == null)
+ _constructionActivator = new ConstructionLevelActivator ();
+
+ return _constructionActivator;
+ }
+ }
public static IMessage Activate (RemotingProxy proxy, ConstructionCall ctorCall)
{
IMessage response;
+ ctorCall.SourceProxy = proxy;
if (Thread.CurrentContext.HasExitSinks && !ctorCall.IsContextOk)
response = Thread.CurrentContext.GetClientContextSinkChain ().SyncProcessMessage (ctorCall);
else
response = RemoteActivate (ctorCall);
- if (response is IConstructionReturnMessage && ((IConstructionReturnMessage)response).Exception == null)
+ if (response is IConstructionReturnMessage && ((IConstructionReturnMessage)response).Exception == null && proxy.ObjectIdentity == null)
{
Identity identity = RemotingServices.GetMessageTargetIdentity (ctorCall);
proxy.AttachIdentity (identity);
public static IMessage RemoteActivate (IConstructionCallMessage ctorCall)
{
- try \r
+ try
{
return ctorCall.Activator.Activate (ctorCall);
}
- catch (Exception ex) \r
+ catch (Exception ex)
{
return new ReturnMessage (ex, ctorCall);
- } \r
+ }
}
public static object CreateProxyFromAttributes (Type type, object[] activationAttributes)
if (!type.IsContextful)
{
// Must be a remote activated object
- ctorCall.Activator = new AppDomainLevelActivator (activationUrl, _constructionActivator);
+ ctorCall.Activator = new AppDomainLevelActivator (activationUrl, ConstructionActivator);
ctorCall.IsContextOk = false; // It'll be activated in a remote context
return ctorCall;
}
// It is a CBO. Need collect context properties and
// check if a new context is needed.
- IActivator activatorChain = _constructionActivator;
+ IActivator activatorChain = ConstructionActivator;
activatorChain = new ContextLevelActivator (activatorChain);
ArrayList attributes = new ArrayList ();
public static IMessage CreateInstanceFromMessage (IConstructionCallMessage ctorCall)
{
object obj = AllocateUninitializedClassInstance (ctorCall.ActivationType);
- ctorCall.MethodBase.Invoke (obj, ctorCall.Args);
ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (ctorCall);
-
identity.AttachServerObject ((MarshalByRefObject) obj, Threading.Thread.CurrentContext);
+ ConstructionCall call = ctorCall as ConstructionCall;
+
+ if (ctorCall.ActivationType.IsContextful && call != null && call.SourceProxy != null)
+ {
+ call.SourceProxy.AttachIdentity (identity);
+ MarshalByRefObject target = (MarshalByRefObject) call.SourceProxy.GetTransparentProxy ();
+ RemotingServices.InternalExecuteMessage (target, ctorCall);
+ }
+ else
+ ctorCall.MethodBase.Invoke (obj, ctorCall.Args);
+
return new ConstructionResponse (obj, null, ctorCall);
}
if (type.IsContextful)
return RemotingServices.CreateClientProxyForContextBound (type, null);
-
+#if !NET_2_1
+ if (type.IsCOMObject) {
+ return RemotingServices.CreateClientProxyForComInterop (type);
+ }
+#endif
return null;
}