21 internal const int FLG_MARSHALED_OBJECT = 1;
23 internal const int FLG_WELLKNOWN_OBJREF = 2;
25 internal const int FLG_LITE_OBJREF = 4;
27 internal const int FLG_PROXY_ATTRIBUTE = 8;
37 internal int objrefFlags;
41 internal int domainID;
47 public virtual string URI 91 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
102 internal void SetServerIdentity(
GCHandle hndSrvIdentity)
104 srvIdentity = hndSrvIdentity;
107 internal GCHandle GetServerIdentity()
112 internal void SetDomainID(
int id)
117 internal int GetDomainID()
126 typeInfo = o.typeInfo;
127 envoyInfo = o.envoyInfo;
128 channelInfo = o.channelInfo;
129 objrefFlags = o.objrefFlags;
130 SetServerIdentity(o.GetServerIdentity());
131 SetDomainID(o.GetDomainID());
144 RuntimeType runtimeType = requestedType as RuntimeType;
145 if (requestedType !=
null && runtimeType ==
null)
151 Init(o, identity, runtimeType);
165 if (enumerator.
Name.Equals(
"uri"))
167 uri = (string)enumerator.
Value;
169 else if (enumerator.
Name.Equals(
"typeInfo"))
173 else if (enumerator.
Name.Equals(
"envoyInfo"))
177 else if (enumerator.
Name.Equals(
"channelInfo"))
181 else if (enumerator.
Name.Equals(
"objrefFlags"))
183 object value = enumerator.
Value;
184 if (value.GetType() == typeof(
string))
190 objrefFlags = (int)value;
193 else if (enumerator.
Name.Equals(
"fIsMarshalled"))
195 object value2 = enumerator.
Value;
196 if (((!(value2.GetType() == typeof(
string))) ? ((int)value2) : ((
IConvertible)value2).ToInt32(
null)) == 0)
201 else if (enumerator.
Name.Equals(
"url"))
203 text = (string)enumerator.
Value;
205 else if (enumerator.
Name.Equals(
"SrvIdentity"))
209 else if (enumerator.
Name.Equals(
"DomainId"))
211 SetDomainID((
int)enumerator.
Value);
230 internal bool CanSmuggle()
232 if (GetType() != typeof(
ObjRef) || IsObjRefLite())
237 if (typeInfo !=
null)
239 left = typeInfo.GetType();
242 if (channelInfo !=
null)
244 left2 = channelInfo.GetType();
246 if ((left ==
null || left == typeof(
TypeInfo) || left == typeof(DynamicTypeInfo)) && envoyInfo ==
null && (left2 ==
null || left2 == typeof(
ChannelInfo)))
248 if (channelInfo !=
null)
251 foreach (
object obj
in channelData)
253 if (!(obj is CrossAppDomainData))
265 internal ObjRef CreateSmuggleableCopy()
282 info.SetType(orType);
285 info.AddValue(
"uri", uri, typeof(
string));
286 info.AddValue(
"objrefFlags", objrefFlags);
288 info.AddValue(
"envoyInfo", envoyInfo, typeof(
IEnvoyInfo));
289 info.AddValue(
"channelInfo", GetChannelInfoHelper(), typeof(
IChannelInfo));
293 info.AddValue(
"url", uri, typeof(
string));
301 if (channelInfo ==
null)
303 return this.channelInfo;
306 if (channelData ==
null)
315 string value = array[0];
316 string text = array[1];
318 channelInfo2.ChannelData =
new object[channelData.Length];
319 for (
int i = 0; i < channelData.Length; i++)
321 channelInfo2.ChannelData[i] = channelData[i];
323 if (channelDataStore !=
null)
325 string[] channelUris = channelDataStore.
ChannelUris;
326 if (channelUris !=
null && channelUris.Length == 1 && channelUris[0].Equals(value))
328 ChannelDataStore channelDataStore2 = channelDataStore.InternalShallowCopy();
331 channelInfo2.ChannelData[i] = channelDataStore2;
345 return GetRealObjectHelper();
349 internal object GetRealObjectHelper()
351 if (!IsMarshaledObject())
360 uri = uri.Substring(num - 1);
363 bool fRefine = !(GetType() == typeof(
ObjRef));
364 object ret = RemotingServices.Unmarshal(
this, fRefine);
365 return GetCustomMarshaledCOMObject(ret);
369 private object GetCustomMarshaledCOMObject(
object ret)
371 DynamicTypeInfo dynamicTypeInfo =
TypeInfo as DynamicTypeInfo;
372 if (dynamicTypeInfo !=
null)
375 IntPtr intPtr = IntPtr.Zero;
380 intPtr = ((__ComObject)ret).GetIUnknown(out
bool fIsURTAggregated);
381 if (!(intPtr != IntPtr.Zero))
385 if (fIsURTAggregated)
389 string typeName =
TypeInfo.TypeName;
390 string typeName2 =
null;
391 string assemName =
null;
394 if (assembly ==
null)
396 throw new RemotingException(Environment.GetResourceString(
"Serialization_AssemblyNotFound", assemName));
398 Type type = assembly.GetType(typeName2, throwOnError:
false, ignoreCase:
false);
399 if (type !=
null && !type.IsVisible)
413 if (intPtr != IntPtr.Zero)
429 internal bool IsMarshaledObject()
431 return (objrefFlags & 1) == 1;
434 internal void SetMarshaledObject()
439 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
440 internal bool IsWellKnown()
442 return (objrefFlags & 2) == 2;
445 internal void SetWellKnown()
450 internal bool HasProxyAttribute()
452 return (objrefFlags & 8) == 8;
455 internal void SetHasProxyAttribute()
460 internal bool IsObjRefLite()
462 return (objrefFlags & 4) == 4;
465 internal void SetObjRefLite()
471 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
472 private CrossAppDomainData GetAppDomainChannelData()
475 CrossAppDomainData crossAppDomainData =
null;
479 if (crossAppDomainData !=
null)
481 return crossAppDomainData;
490 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
497 return GetAppDomainChannelData()?.IsFromThisProcess() ??
false;
505 return GetAppDomainChannelData()?.IsFromThisAppDomain() ??
false;
509 [ReliabilityContract(
Consistency.WillNotCorruptState,
Cer.Success)]
510 internal int GetServerDomainId()
516 CrossAppDomainData appDomainChannelData = GetAppDomainChannelData();
517 return appDomainChannelData.DomainID;
521 internal IntPtr GetServerContext(out
int domainId)
527 CrossAppDomainData appDomainChannelData = GetAppDomainChannelData();
528 domainId = appDomainChannelData.DomainID;
529 if (
AppDomain.IsDomainIdValid(appDomainChannelData.DomainID))
531 result = appDomainChannelData.ContextID;
538 internal void Init(
object o, Identity idObj, RuntimeType requestedType)
541 MarshalByRefObject tPOrObject = idObj.TPOrObject;
542 RuntimeType runtimeType =
null;
543 runtimeType = (RemotingServices.IsTransparentProxy(tPOrObject) ? ((RuntimeType)RemotingServices.GetRealProxy(tPOrObject).GetProxiedType()) : ((RuntimeType)tPOrObject.GetType()));
544 RuntimeType runtimeType2 = (
null == requestedType) ? runtimeType : requestedType;
545 if (
null != requestedType && !requestedType.IsAssignableFrom(runtimeType) && !typeof(
IMessageSink).IsAssignableFrom(runtimeType))
547 throw new RemotingException(
string.Format(
CultureInfo.
CurrentCulture, Environment.GetResourceString(
"Remoting_InvalidRequestedType"), requestedType.
ToString()));
549 if (runtimeType.IsCOMObject)
551 DynamicTypeInfo dynamicTypeInfo = (DynamicTypeInfo)(
TypeInfo =
new DynamicTypeInfo(runtimeType2));
555 RemotingTypeCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(runtimeType2);
556 TypeInfo = reflectionCachedData.TypeInfo;
558 if (!idObj.IsWellKnown())
564 object[] channelData = channelInfo.ChannelData;
565 int num = channelData.Length;
566 object[] array =
new object[num];
567 Array.Copy(channelData, array, num);
568 for (
int i = 0; i < num; i++)
570 if (!(array[i] is CrossAppDomainData))
575 channelInfo.ChannelData = array;
578 if (runtimeType.HasProxyAttribute)
580 SetHasProxyAttribute();
587 if (!ShouldUseUrlObjRef())
604 internal static bool ShouldUseUrlObjRef()
606 return RemotingConfigHandler.UrlObjRefMode;
610 internal static bool IsWellFormed(
ObjRef objectRef)
613 if (objectRef ==
null || objectRef.URI ==
null || (!objectRef.IsWellKnown() && !objectRef.IsObjRefLite() && !(objectRef.GetType() != orType) && objectRef.ChannelInfo ==
null))
virtual string URI
Gets or sets the URI of the specific object instance.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
Describes a set of security permissions applied to code. This class cannot be inherited.
ObjRef()
Initializes a new instance of the T:System.Runtime.Remoting.ObjRef class with default values.
Indicates that the current interface implementer is a reference to another object.
virtual IChannelInfo ChannelInfo
Gets or sets the T:System.Runtime.Remoting.IChannelInfo for the T:System.Runtime.Remoting....
object Value
Gets the value of the item currently being examined.
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a specified T:System.Runtime.Serialization.SerializationInfo with the data needed to serial...
static int Release(IntPtr pUnk)
Decrements the reference count on the specified interface.
Stores all relevant information required to generate a proxy in order to communicate with a remote ob...
ObjRef(SerializationInfo info, StreamingContext context)
Initializes a new instance of the T:System.Runtime.Remoting.ObjRef class from serialized data.
Describes the source and destination of a given serialized stream, and provides an additional caller-...
Represents an application domain, which is an isolated environment where applications execute....
override string ToString()
Returns a string containing the name of the current T:System.Globalization.CultureInfo in the format ...
Represents type declarations for class types, interface types, array types, value types,...
ObjRef(MarshalByRefObject o, Type requestedType)
Initializes a new instance of the T:System.Runtime.Remoting.ObjRef class to reference a specified T:S...
Cer
Specifies a method's behavior when called within a constrained execution region.
Permission to configure Remoting types and channels.
string [] ChannelUris
Gets or sets an array of channel URIs that the current channel maps to.
SecurityAction
Specifies the security actions that can be performed using declarative security.
Provides information about, and means to manipulate, the current environment and platform....
Provides a set of properties that are carried with the execution code path. This class cannot be inhe...
static object GetTypedObjectForIUnknown(IntPtr pUnk, Type t)
Returns a managed object of a specified type that represents a COM object.
Represents an assembly, which is a reusable, versionable, and self-describing building block of a com...
A platform-specific type that is used to represent a pointer or a handle.
Provides static methods to aid with remoting channel registration, resolution, and URL discovery....
Represents type declarations: class types, interface types, array types, value types,...
Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks,...
Provides a way to access a managed object from unmanaged memory.
virtual IEnvoyInfo EnvoyInfo
Gets or sets the T:System.Runtime.Remoting.IEnvoyInfo for the T:System.Runtime.Remoting....
bool IsFromThisProcess()
Returns a Boolean value that indicates whether the current T:System.Runtime.Remoting....
virtual IRemotingTypeInfo TypeInfo
Gets or sets the T:System.Runtime.Remoting.IRemotingTypeInfo for the object that the T:System....
Provides type information for an object.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
static CultureInfo CurrentCulture
Gets or sets the T:System.Globalization.CultureInfo object that represents the culture used by the cu...
The exception that is thrown when one of the arguments provided to a method is not valid.
Provides custom channel information that is carried along with the T:System.Runtime....
Allows an object to control its own serialization and deserialization.
Provides envoy information.
static object GetData(string name)
Retrieves an object with the specified name from the T:System.Runtime.Remoting.Messaging....
virtual object GetRealObject(StreamingContext context)
Returns a reference to the remote object that the T:System.Runtime.Remoting.ObjRef describes.
Stores channel data for the remoting channels.
static readonly IntPtr Zero
A read-only field that represents a pointer or handle that has been initialized to zero.
Defines the interface for a message sink.
Specifies that the class can be serialized.
string Name
Gets the name for the item currently being examined.
Consistency
Specifies a reliability contract.
Provides information about a specific culture (called a locale for unmanaged code development)....
Defines methods that convert the value of the implementing reference or value type to a common langua...
SecurityPermissionFlag
Specifies access flags for the security permission object.
Provides a formatter-friendly mechanism for parsing the data in T:System.Runtime.Serialization....
bool IsFromThisAppDomain()
Returns a Boolean value that indicates whether the current T:System.Runtime.Remoting....
object [] ChannelData
Gets and sets the channel data for each channel.
bool MoveNext()
Updates the enumerator to the next item.
Enables access to objects across application domain boundaries in applications that support remoting.