This topic has not yet been rated - Rate this topic

Context Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Defines an environment for the objects that are resident inside it and for which a policy can be enforced.

System.Object
  System.Runtime.Remoting.Contexts.Context

Namespace:  System.Runtime.Remoting.Contexts
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)]
public class Context

The Context type exposes the following members.

  Name Description
Public method Context Infrastructure. Initializes a new instance of the Context class.
Top
  Name Description
Public property ContextID Infrastructure. Gets the context ID for the current context.
Public property ContextProperties Infrastructure. Gets the array of the current context properties.
Public property Static member DefaultContext Infrastructure. Gets the default context for the current application domain.
Top
  Name Description
Public method Static member AllocateDataSlot Infrastructure. Allocates an unnamed data slot.
Public method Static member AllocateNamedDataSlot Infrastructure. Allocates a named data slot.
Public method DoCallBack Infrastructure. Executes code in another context.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Infrastructure. Cleans up the backing objects for the nondefault contexts. (Overrides Object.Finalize().)
Public method Static member FreeNamedDataSlot Infrastructure. Frees a named data slot on all the contexts.
Public method Freeze Infrastructure. Freezes the context, making it impossible to add or remove context properties from the current context.
Public method Static member GetData Infrastructure. Retrieves the value from the specified slot on the current context.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method Static member GetNamedDataSlot Infrastructure. Looks up a named data slot.
Public method GetProperty Infrastructure. Returns a specific context property, specified by name.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Static member RegisterDynamicProperty Infrastructure. Registers a dynamic property implementing the IDynamicProperty interface with the remoting service.
Public method Static member SetData Infrastructure. Sets the data in the specified slot on the current context.
Public method SetProperty Infrastructure. Sets a specific context property by name.
Public method ToString Infrastructure. Returns a String class representation of the current context. (Overrides Object.ToString().)
Public method Static member UnregisterDynamicProperty Infrastructure. Unregisters a dynamic property implementing the IDynamicProperty interface.
Top

A context is an ordered sequence of properties that define an environment for the objects resident inside it. Contexts get created during the activation process for objects that are configured to require certain automatic services, such as synchronization, transactions, just-in-time activation, security, and so on. Multiple objects can live inside a context.

Classes are marked with an instance of the ContextAttribute class, which provides the usage rules. Whenever a new object is instantiated, the .NET Framework finds a compatible or creates a new instance of the Context class for the object. Once an object is placed in a context, it stays in it for life. Classes that can be bound to a context are called context-bound classes. When accessed from another context, such classes are referenced directly by using a proxy. Any call from an object in one context to an object in another context will go through a context proxy and be affected by the policy that the combined context properties enforce.

A new object's context is generally chosen based on meta-data attributes on the class. This mechanism is extensible through custom attributes. These are known as static-context properties, which are compiled into the class meta-data. Dynamic-context properties (also known as configuration properties) can be applied and configured by administrators.

For more information on contexts, see [<topic://cpconboundariesprocessesapplicationdomainscontexts>].

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8 Release Preview, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 SP2, Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)