ProxyAttribute Class
Indicates that an object type requires a custom proxy.
Assembly: mscorlib (in mscorlib.dll)
[SecurityCriticalAttribute] [AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = false, Inherited = true)] [ComVisibleAttribute(true)] [SecurityPermissionAttribute(SecurityAction::InheritanceDemand, Flags = SecurityPermissionFlag::Infrastructure)] public ref class ProxyAttribute : Attribute, IContextAttribute
| Name | Description | |
|---|---|---|
![]() | ProxyAttribute() | Initializes a new instance of the ProxyAttribute class with default values. |
| Name | Description | |
|---|---|---|
![]() | CreateInstance(Type^) | Creates either an uninitialized MarshalByRefObject or a transparent proxy, depending on whether the specified type can exist in the current context. |
![]() | CreateProxy(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. |
![]() | Equals(Object^) | 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.) |
![]() | 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(IConstructionCallMessage^) | Gets properties for a new context. |
![]() | GetType() | |
![]() | IsContextOK(Context^, IConstructionCallMessage^) | 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(Object^) | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.(Inherited from Attribute.) |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute::GetIDsOfNames(Guid%, IntPtr, UInt32, UInt32, IntPtr) | Maps a set of names to a corresponding set of dispatch identifiers.(Inherited from Attribute.) |
![]() ![]() | _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.) |
![]() ![]() | _Attribute::GetTypeInfoCount(UInt32%) | Retrieves the number of type information interfaces that an object provides (either 0 or 1).(Inherited from Attribute.) |
![]() ![]() | _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.)
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 ); } };
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
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.





