CallContext::SetHeaders Method (array<Header^>^)

 

Sets the headers that are sent along with the method call.

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

public:
[SecurityCriticalAttribute]
static void SetHeaders(
	array<Header^>^ headers
)

Parameters

headers
Type: array<System.Runtime.Remoting.Messaging::Header^>^

A Header array of the headers that are to be sent along with the method call.

Exception Condition
SecurityException

The immediate caller does not have infrastructure permission.

The following example code shows the ease with which a header is put on the logical thread.

public ref class HelloService: public MarshalByRefObject
{
public:
   String^ HelloMethod( String^ name )
   {
      Console::WriteLine( "Hello {0}", name );
      return "Hello {0}",name;
   }


   [SecurityPermissionAttribute(SecurityAction::Demand, Flags=SecurityPermissionFlag::Infrastructure)]
   String^ HeaderMethod( String^ name, array<Header^>^arrHeader )
   {
      Console::WriteLine( "HeaderMethod {0}", name );

      //Header Set with the header array passed
      CallContext::SetHeaders( arrHeader );
      return "HeaderMethod {0}",name;
   }
};

SecurityPermission

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

.NET Framework
Available since 1.1
Return to top
Show: