CallContext.SetHeaders(Header[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Sets the headers that are sent along with the method call.
public:
static void SetHeaders(cli::array <System::Runtime::Remoting::Messaging::Header ^> ^ headers);
public static void SetHeaders (System.Runtime.Remoting.Messaging.Header[] headers);
[System.Security.SecurityCritical]
public static void SetHeaders (System.Runtime.Remoting.Messaging.Header[] headers);
static member SetHeaders : System.Runtime.Remoting.Messaging.Header[] -> unit
[<System.Security.SecurityCritical>]
static member SetHeaders : System.Runtime.Remoting.Messaging.Header[] -> unit
Public Shared Sub SetHeaders (headers As Header())
Parameters
- Attributes
Exceptions
The immediate caller does not have infrastructure permission.
Examples
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;
}
};
public class HelloService : MarshalByRefObject
{
public string HelloMethod(string name)
{
Console.WriteLine("Hello " + name);
return "Hello " + name;
}
public string HeaderMethod(string name,Header[] arrHeader)
{
Console.WriteLine("HeaderMethod " + name);
//Header Set with the header array passed
CallContext.SetHeaders(arrHeader);
return "HeaderMethod " + name;
}
}
Public Class HelloService
Inherits MarshalByRefObject
Public Function HelloMethod(name As String) As String
Console.WriteLine(("Hello " + name))
Return "Hello " + name
End Function 'HelloMethod
<PermissionSet(SecurityAction.LinkDemand)> _
Public Function HeaderMethod(name As String, arrHeader() As Header) As String
Console.WriteLine("HeaderMethod " + name)
'Header Set with the header array passed
CallContext.SetHeaders(arrHeader)
Return "HeaderMethod " + name
End Function 'HeaderMethod
End Class
Applies to
Συνεργαστείτε μαζί μας στο GitHub
Μπορείτε να βρείτε την πηγή για αυτό το περιεχόμενο στο GitHub, όπου μπορείτε επίσης να δημιουργήσετε και να εξετάσετε ζητήματα και αιτήματα έλξης. Για περισσότερες πληροφορίες, ανατρέξτε στον οδηγό συνεργατών.