Merge pull request #1135 from kitsilanosoftware/rpm-spec-dead-entries
[mono.git] / mcs / class / corlib / System.Runtime.Remoting.Activation / ActivationServices.cs
index 2149edb40f5d32922f817d8e756cda71bf9b49de..3756f1df9b0f3820050a438e0c0a8cc625328698 100644 (file)
@@ -44,7 +44,16 @@ namespace System.Runtime.Remoting.Activation
 {
        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)
                {
@@ -106,7 +115,7 @@ namespace System.Runtime.Remoting.Activation
                        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;
                        }
@@ -114,7 +123,7 @@ namespace System.Runtime.Remoting.Activation
                        // 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 ();
@@ -173,6 +182,7 @@ namespace System.Runtime.Remoting.Activation
                        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);
@@ -203,11 +213,11 @@ namespace System.Runtime.Remoting.Activation
 
                        if (type.IsContextful)
                                return RemotingServices.CreateClientProxyForContextBound (type, null);
-
+#if !NET_2_1
                        if (type.IsCOMObject) {
                                return RemotingServices.CreateClientProxyForComInterop (type);
                        }
-
+#endif
                        return null;
                }