// TODO: @cleanup: Move to ServicedComponentProxy private static void ReconnectForPooling(ServicedComponentProxy scp) { Type serverType = scp.GetProxiedType(); bool fIsJitActivated = scp.IsJitActivated; bool fIsTypePooled = scp.IsObjectPooled; bool fAreMethodsSecure = scp.AreMethodsSecure; ProxyTearoff tearoff = null; DBG.Assert(fIsTypePooled == true, "CS.ReconnectForPooling called on a non-pooled proxy!"); DBG.Info(DBG.SC, "CS.ReconnectForPooling (type is pooled) " + serverType); ServicedComponent server = scp.DisconnectForPooling(ref tearoff); // now setup a new SCP that we can add to the pool // with the current server object and the CCW ServicedComponentProxy newscp = new ServicedComponentProxy(serverType, fIsJitActivated, fIsTypePooled, fAreMethodsSecure, false); DBG.Info(DBG.SC, "CS.ReconnectForPooling (calling newscp.ConnectForPooling)"); newscp.ConnectForPooling(scp, server, tearoff, false); // switch the CCW from oldtp to new tp DBG.Info(DBG.SC, "CS.ReconnectForPooling (SwitchingWrappers)"); EnterpriseServicesHelper.SwitchWrappers(scp, newscp); // Strengthen the CCW: The only reference now held is // the reference from the pool. if (tearoff != null) { Marshal.ChangeWrapperHandleStrength(tearoff, false); } Marshal.ChangeWrapperHandleStrength(newscp.GetTransparentProxy(), false); }
void IObjectControl.Deactivate() { ServicedComponentProxy target = (ServicedComponentProxy)this._scp.Target; if (target != null) { ComponentServices.DeactivateObject(target.GetTransparentProxy(), true); } }
private static void ReconnectForPooling(ServicedComponentProxy scp) { Type proxiedType = scp.GetProxiedType(); bool isJitActivated = scp.IsJitActivated; bool isObjectPooled = scp.IsObjectPooled; bool areMethodsSecure = scp.AreMethodsSecure; ProxyTearoff proxyTearoff = null; ServicedComponent server = scp.DisconnectForPooling(ref proxyTearoff); ServicedComponentProxy newcp = new ServicedComponentProxy(proxiedType, isJitActivated, isObjectPooled, areMethodsSecure, false); newcp.ConnectForPooling(scp, server, proxyTearoff, false); EnterpriseServicesHelper.SwitchWrappers(scp, newcp); if (proxyTearoff != null) { Marshal.ChangeWrapperHandleStrength(proxyTearoff, false); } Marshal.ChangeWrapperHandleStrength(newcp.GetTransparentProxy(), false); }
private static void ReconnectForPooling(ServicedComponentProxy scp) { Type proxiedType = scp.GetProxiedType(); bool isJitActivated = scp.IsJitActivated; bool isObjectPooled = scp.IsObjectPooled; bool areMethodsSecure = scp.AreMethodsSecure; ProxyTearoff proxyTearoff = null; ServicedComponent server = scp.DisconnectForPooling(ref proxyTearoff); ServicedComponentProxy newcp = new ServicedComponentProxy(proxiedType, isJitActivated, isObjectPooled, areMethodsSecure, false); newcp.ConnectForPooling(scp, server, proxyTearoff, false); EnterpriseServicesHelper.SwitchWrappers(scp, newcp); if (proxyTearoff != null) { Marshal.ChangeWrapperHandleStrength(proxyTearoff, false); } Marshal.ChangeWrapperHandleStrength(newcp.GetTransparentProxy(), false); }