public override void GetObjectData(SerializationInfo info, StreamingContext context) { ComponentServices.InitializeRemotingChannels(); if (info == null) { throw new ArgumentNullException("info"); } object data = CallContext.GetData("__ClientIsClr"); if ((data != null) && ((bool)data)) { RemoteServicedComponentProxy proxy = this._rp as RemoteServicedComponentProxy; if (proxy != null) { RemotingServices.Marshal((MarshalByRefObject)proxy.RemotingIntermediary.GetTransparentProxy(), null, null).GetObjectData(info, context); } else { base.GetObjectData(info, context); } } else { base.GetObjectData(info, context); info.SetType(typeof(ServicedComponentMarshaler)); info.AddValue("servertype", this._rp.GetProxiedType()); byte[] dCOMBuffer = ComponentServices.GetDCOMBuffer((MarshalByRefObject)this._rp.GetTransparentProxy()); if (dCOMBuffer != null) { info.AddValue("dcomInfo", dCOMBuffer); } } }
public void GetObjectData(object obj, SerializationInfo info, StreamingContext ctx) { if (!obj.GetType().IsCOMObject) { throw new NotSupportedException(); } info.SetType(typeof(ComObjRef)); info.AddValue("buffer", ComponentServices.GetDCOMBuffer(obj)); }
// copied from ServicedComponentMarshaler above directly // IF YOU MAK ANY CHANGES TO THIS, KEEP THE OTHER COPY IN SYNC public override void GetObjectData(SerializationInfo info, StreamingContext context) { DBG.Info(DBG.SC, "FSCM: GetObjectData"); ComponentServices.InitializeRemotingChannels(); if (info == null) { throw new ArgumentNullException("info"); } // Check to see if this is a remoting channel, if so, then we // should use the standard objref marshal (cause we're going over SOAP // or another remoting channel). object oClientIsClr = CallContext.GetData("__ClientIsClr"); DBG.Info(DBG.SC, "FSCM: GetObjectData: oClientIsClr = " + oClientIsClr); bool bUseStandardObjRef = (oClientIsClr == null)?false:(bool)oClientIsClr; if (bUseStandardObjRef) { RemoteServicedComponentProxy rscp = _rp as RemoteServicedComponentProxy; if (rscp != null) { DBG.Info(DBG.SC, "FSCM: GetObjectData: intermediary objref"); ObjRef std = RemotingServices.Marshal((MarshalByRefObject)(rscp.RemotingIntermediary.GetTransparentProxy()), null, null); std.GetObjectData(info, context); } else { DBG.Info(DBG.SC, "FSCM: GetObjectData: Using standard objref"); base.GetObjectData(info, context); } } else { DBG.Info(DBG.SC, "FSCM: GetObjectData: Using custom objref"); base.GetObjectData(info, context); //*** base.GetObjectData sets the type to be itself // now wack the type to be us info.SetType(typeof(ServicedComponentMarshaler)); DBG.Assert(_rp != null, "_rp is null"); info.AddValue("servertype", _rp.GetProxiedType()); byte[] dcomBuffer = ComponentServices.GetDCOMBuffer((MarshalByRefObject)_rp.GetTransparentProxy()); DBG.Assert(dcomBuffer != null, "dcomBuffer is null"); if (dcomBuffer != null) { info.AddValue("dcomInfo", dcomBuffer); } } }