CallContext::GetHeaders Method ()
.NET Framework (current version)
Returns the headers that are sent along with the method call.
Assembly: mscorlib (in mscorlib.dll)
Return Value
Type: array<System.Runtime.Remoting.Messaging::Header^>^The headers that are sent along with the method call.
| Exception | Condition |
|---|---|
| SecurityException | The immediate caller does not have infrastructure permission. |
The following code example sends headers to a remote method and prints the content of those headers to the console when the remote method returns.
// Array of Headers with name and values initialized. array<Header^>^ myArrSetHeader = { gcnew Header( "Header0","CallContextHeader0" ), gcnew Header( "Header1","CallContextHeader1" ) }; // Pass the Header Array with method call. // Header will be set in the method by'CallContext::SetHeaders' method in remote Object*. Console::WriteLine( "Remote HeaderMethod output is {0}", myService->HeaderMethod( "CallContextHeader", myArrSetHeader ) ); array<Header^>^ myArrGetHeader; // Get Header Array. myArrGetHeader = CallContext::GetHeaders(); if ( nullptr == myArrGetHeader ) { Console::WriteLine( "CallContext::GetHeaders Failed" ); } else { Console::WriteLine( "Headers:" ); } for each ( Header^ myHeader in myArrGetHeader ) { Console::WriteLine( "Value in Header '{0}' is '{1}'.", myHeader->Name, myHeader->Value ); }
SecurityPermission
For operating with infrastructure code. Demand value: SecurityAction::LinkDemand; Permission value: SecurityPermissionFlag::Infrastructure
.NET Framework
Available since 1.1
Available since 1.1
Show: