Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ProxyAttribute Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Indicates that an object type requires a custom proxy.

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


[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = false, 
	Inherited = true)]
	Flags = SecurityPermissionFlag.Infrastructure)]
public class ProxyAttribute : Attribute, IContextAttribute


Initializes a new instance of the ProxyAttribute class with default values.


When implemented in a derived class, gets a unique identifier for this Attribute.(Inherited from Attribute.)


Creates either an uninitialized MarshalByRefObject or a transparent proxy, depending on whether the specified type can exist in the current context.

System_CAPS_pubmethodCreateProxy(ObjRef, Type, Object, Context)

Creates an instance of a remoting proxy for a remote object described by the specified ObjRef, and located on the server.


This API supports the product infrastructure and is not intended to be used directly from your code. Returns a value that indicates whether this instance is equal to a specified object.(Inherited from Attribute.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Returns the hash code for this instance.(Inherited from Attribute.)


Gets properties for a new context.


Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodIsContextOK(Context, IConstructionCallMessage)

Checks the specified context.


When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.(Inherited from Attribute.)


When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.(Inherited from Attribute.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Maps a set of names to a corresponding set of dispatch identifiers.(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

Retrieves the type information for an object, which can be used to get the type information for an interface.(Inherited from Attribute.)


Retrieves the number of type information interfaces that an object provides (either 0 or 1).(Inherited from Attribute.)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.(Inherited from Attribute.)

Apply the current attribute to types that need custom proxies. You can use the ProxyAttribute class to intercept the new (New in Visual Basic) statement by deriving from the ProxyAttribute and placing the attribute on a child of ContextBoundObject. (Placing the proxy attribute on a child of MarshalByRefObject is not supported.)


This class makes a link demand and an inheritance demand at the class level. A SecurityException is thrown when either the immediate caller or the derived class does not have infrastructure permission. For details about security demands, see Link Demands and Inheritance Demands.

[SecurityPermissionAttribute(SecurityAction.Demand, Flags=SecurityPermissionFlag.Infrastructure)]
public class MyProxyAttribute : ProxyAttribute
   public MyProxyAttribute()
   // Create an instance of ServicedComponentProxy
   public override MarshalByRefObject CreateInstance(Type serverType)
      return base.CreateInstance(serverType);
   public override RealProxy CreateProxy(ObjRef objRef1,
      Type serverType,
      object serverObject,
      Context serverContext)
      MyProxy myCustomProxy = new MyProxy(serverType);
      if(serverContext != null)
      if((!serverType.IsMarshalByRef)&&(serverContext == null))
         throw new RemotingException("Bad Type for CreateProxy");
      return myCustomProxy;
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
public class CustomServer :ContextBoundObject
   public CustomServer()
      Console.WriteLine("CustomServer Base Class constructor called");
   public void HelloMethod(string str)
      Console.WriteLine("HelloMethod of Server is invoked with message : " + str);


For operating with infrastructure code. Demand value: SecurityAction.LinkDemand; Permission Value: SecurityPermissionFlag.Infrastructure


For operating with infrastructure code. Demand value: SecurityAction.InheritanceDemand; Permission Value: SecurityPermissionFlag.Infrastructure

.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
© 2017 Microsoft