This documentation is archived and is not being maintained.
MessageQueuePermissionEntry Class
Visual Studio 2010
Defines the smallest unit of a code access security permission set for messaging.
Assembly: System.Messaging (in System.Messaging.dll)
The MessageQueuePermissionEntry type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | MessageQueuePermissionEntry(MessageQueuePermissionAccess, String) | Initializes a new instance of the MessageQueuePermissionEntry class with the specified permission access levels and the path of the queue. |
![]() | MessageQueuePermissionEntry(MessageQueuePermissionAccess, String, String, String) | Initializes a new instance of the MessageQueuePermissionEntry class with the specified permission access levels, the name of the computer where the queue is located, the queue description, and the queue category. |
| Name | Description | |
|---|---|---|
![]() | Category | Gets the queue category. |
![]() | Label | Gets the queue description. |
![]() | MachineName | Gets the name of the computer where the Message Queuing queue is located. |
![]() | Path | Gets the queue's path. |
![]() | PermissionAccess | Gets the permission access levels used in the permissions request. |
| Name | Description | |
|---|---|---|
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | 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 | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
For more information, see Code Access Security.
The following code example demonstrates the use of MessageQueuePermissionEntry.
#using <System.Messaging.dll> #using <System.dll> using namespace System; using namespace System::Messaging; public ref class MessageQueuePermissionEntryExample { // Creates a new queue. public: static void CreateQueue(String^ queuePath, bool transactional) { if(!MessageQueue::Exists(queuePath)) { MessageQueue^ queue = MessageQueue::Create(queuePath, transactional); queue->Close(); } else { Console::WriteLine("{0} already exists.", queuePath); } } // Demonstrates the following MessageQueuePermission constructor: // public #ctor (MessageQueuePermissionAccess permissionAccess, // String path) public: void CreateEntryShortCtor() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->Path); queue->Close(); } // Demonstrates the following MessageQueuePermission constructor: // public #ctor (MessageQueuePermissionAccess permissionAccess, // String machineName, String label, String category) public: void CreateEntryLongCtor() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->MachineName, queue->Label, queue->Category.ToString()); queue->Close(); } public: void CategoryExample() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->MachineName, queue->Label, queue->Category.ToString()); // Display the value of the entry's Category property. Console::WriteLine("Category: {0}", entry->Category->ToString()); queue->Close(); } public: void LabelExample() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->MachineName, queue->Label, queue->Category.ToString()); // Display the value of the entry's Label property. Console::WriteLine("Label: {0}", entry->Label); queue->Close(); } public: void MachineNameExample() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->MachineName, queue->Label, queue->Category.ToString()); // Display the value of the entry's MachineName property. Console::WriteLine("MachineName: {0}", entry->MachineName); queue->Close(); } public: void PathExample() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->Path); // Display the value of the entry's Path property. Console::WriteLine("Path: {0}", entry->Path); queue->Close(); } public: void PermissionAccessExample() { // Connect to a queue on the local computer. MessageQueue^ queue = gcnew MessageQueue(".\\exampleQueue"); // Create a new instance of MessageQueuePermissionEntry. MessageQueuePermissionEntry^ entry = gcnew MessageQueuePermissionEntry( MessageQueuePermissionAccess::Receive, queue->MachineName, queue->Label, queue->Category.ToString()); // Display the value of the entry's PermissionAccess property. Console::WriteLine("PermissionAccess: {0}", entry->PermissionAccess); queue->Close(); } }; int main() { // Create a new instance of the class. MessageQueuePermissionEntryExample^ example = gcnew MessageQueuePermissionEntryExample(); try { // Create a non-transactional queue on the local computer. // Note that the queue might not be immediately accessible, and // therefore this example might throw an exception of type // System.Messaging.MessageQueueException when trying to send a // message to the newly created queue. example->CreateQueue(".\\exampleQueue", false); // Demonstrate MessageQueuePermissionEntry's constructors. example->CreateEntryShortCtor(); example->CreateEntryLongCtor(); // Demonstrate MessageQueuePermissionEntry's properties. example->CategoryExample(); example->LabelExample(); example->MachineNameExample(); example->PathExample(); example->PermissionAccessExample(); } catch (InvalidOperationException^) { Console::WriteLine("Please install Message Queuing."); } catch (MessageQueueException^ ex) { // Write the exception information to the console. Console::WriteLine(ex->Message); } }
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.
Show:
