ProxyAttribute Class
Indicates that an object type requires a custom proxy.
Assembly: mscorlib (in mscorlib.dll)
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)] [ComVisibleAttribute(true)] [SecurityPermissionAttribute(SecurityAction::InheritanceDemand, Flags = SecurityPermissionFlag::Infrastructure)] public ref class ProxyAttribute : public Attribute, IContextAttribute
The ProxyAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ProxyAttribute | Initializes a new instance of the ProxyAttribute class with default values. |
| Name | Description | |
|---|---|---|
![]() | CreateInstance | Creates either an uninitialized MarshalByRefObject or a transparent proxy, depending on whether the specified type can exist in the current context. |
![]() | CreateProxy | Creates an instance of a remoting proxy for a remote object described by the specified ObjRef, and located on the server. |
![]() | Equals | Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from Attribute.) |
![]() | GetPropertiesForNewContext | Gets properties for a new context. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsContextOK | Checks the specified context. |
![]() | IsDefaultAttribute | When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames | Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfo | Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.) |
![]() ![]() | _Attribute::GetTypeInfoCount | Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.) |
![]() ![]() | _Attribute::Invoke | 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.)
Note |
|---|
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. |
[AttributeUsageAttribute(AttributeTargets::Class)] [System::Security::Permissions::SecurityPermissionAttribute (System::Security::Permissions::SecurityAction::LinkDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] [System::Security::Permissions::SecurityPermissionAttribute (System::Security::Permissions::SecurityAction::InheritanceDemand, Flags=System::Security::Permissions::SecurityPermissionFlag::Infrastructure)] public ref class MyProxyAttribute: public ProxyAttribute { public: MyProxyAttribute(){} // Create an instance of ServicedComponentProxy virtual MarshalByRefObject^ CreateInstance( Type^ serverType ) override { return ProxyAttribute::CreateInstance( serverType ); } virtual RealProxy^ CreateProxy( ObjRef^ objRef1, Type^ serverType, Object^ serverObject, Context^ serverContext ) override { MyProxy^ myCustomProxy = gcnew MyProxy( serverType ); if ( serverContext != nullptr ) { RealProxy::SetStubData( myCustomProxy, serverContext ); } if ( ( !serverType->IsMarshalByRef) && (serverContext == nullptr) ) { throw gcnew RemotingException( "Bad Type for CreateProxy" ); } return myCustomProxy; } }; [MyProxyAttribute] ref class CustomServer: public ContextBoundObject { public: CustomServer() { Console::WriteLine( "CustomServer Base Class constructor called" ); } void HelloMethod( String^ str ) { Console::WriteLine( "HelloMethod of Server is invoked with message : {0}", str ); } };
- SecurityPermission
For operating with infrastructure code. Demand value: SecurityAction::LinkDemand; Permission Value: SecurityPermissionFlag::Infrastructure
- SecurityPermission
For operating with infrastructure code. Demand value: SecurityAction::InheritanceDemand; Permission Value: SecurityPermissionFlag::Infrastructure
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
