MessageQueueException 類別

定義

發生 Microsoft Message Queuing 內部錯誤時,所擲回的例外狀況。

public ref class MessageQueueException : System::Runtime::InteropServices::ExternalException
[System.Serializable]
public class MessageQueueException : System.Runtime.InteropServices.ExternalException
[<System.Serializable>]
type MessageQueueException = class
    inherit ExternalException
    interface ISerializable
[<System.Serializable>]
type MessageQueueException = class
    inherit ExternalException
Public Class MessageQueueException
Inherits ExternalException
繼承
屬性
實作

範例

#using <system.dll>
#using <system.messaging.dll>

using namespace System;
using namespace System::Messaging;
int main()
{
   
   // Determine whether the queue exists.
   if ( MessageQueue::Exists( ".\\myQueue" ) )
   {
      try
      {
         
         // Delete the queue.
         MessageQueue::Delete( ".\\myQueue" );
      }
      catch ( MessageQueueException^ e ) 
      {
         if ( e->MessageQueueErrorCode == MessageQueueErrorCode::AccessDenied )
         {
            Console::WriteLine( "Access is denied. Queue might be a system queue." );
         }
         
         // Handle other sources of MessageQueueException.
      }

   }

   return 0;
}
using System;
using System.Messaging;

namespace MyProject
{
    /// <summary>
    /// Provides a container class for the example.
    /// </summary>
    public class MyNewQueue
    {

        //**************************************************
        // Provides an entry point into the application.
        //		
        // This example verifies existence and attempts to
        // delete a queue.
        //**************************************************

        public static void Main()
        {

            // Determine whether the queue exists.
            if (MessageQueue.Exists(".\\myQueue"))
            {
                try
                {
                    // Delete the queue.
                    MessageQueue.Delete(".\\myQueue");
                }
                catch(MessageQueueException e)
                {
                    if(e.MessageQueueErrorCode ==
                        MessageQueueErrorCode.AccessDenied)
                    {
                        Console.WriteLine("Access is denied. " +
                            "Queue might be a system queue.");
                    }

                    // Handle other sources of MessageQueueException.
                }
            }
        
            return;
        }
    }
}
Imports System.Messaging



Public Class MyNewQueue


        
        ' Provides an entry point into the application.
        '		 
        ' This example verifies existence and attempts to 
        ' delete a queue.
        

        Public Shared Sub Main()

            ' Determine whether the queue exists.
            If MessageQueue.Exists(".\myQueue") Then

                Try

                    ' Delete the queue.
                    MessageQueue.Delete(".\myQueue")

                Catch e As MessageQueueException

                    If e.MessageQueueErrorCode = _
                        MessageQueueErrorCode.AccessDenied Then

                        Console.WriteLine("Access is denied. " _
                            + "Queue might be a system queue.")
                    End If

                    ' Handle other sources of exceptions as necessary.

                End Try

            End If


            Return

        End Sub

End Class

備註

MessageQueueException 類別相關聯的例外狀況是由訊息佇列內部錯誤所產生,這些錯誤應該透過您的程式碼來處理。

每個例外狀況都包含錯誤碼和描述錯誤來源的文字字串。 MessageQueueErrorCode如需這些錯誤碼及其描述的清單,請參閱 類別。

如果 MessageQueue 開啟一個佇列,而佇列中帶有設定為 true 的 sharedModeDenyReceive 參數,則後續嘗試從佇列讀取的任何 MessageQueue 都會因為共用違規的緣故,產生 MessageQueueException 例外狀況。 如果 MessageQueue 在獨佔模式中嘗試存取該佇列,而另一個 MessageQueue 已擁有該佇列的非獨佔存取,就會擲回相同的例外狀況。

不支援警示標籤!!!!
MessageQueueTransaction 是 threading-apartment-aware。 Visual Basic 會將主執行緒的狀態設定為 STA ,因此您必須在 Main 副程式中套用 MTAThreadAttribute 。 否則,使用其他執行緒傳送交易式訊息時,會擲回 MessageQueueException 例外狀況。

建構函式

MessageQueueException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 MessageQueueException 類別的新執行個體。

屬性

Data

取得鍵值組的集合,這些鍵值組會提供關於例外狀況的其他使用者定義資訊。

(繼承來源 Exception)
ErrorCode

取得錯誤的 HRESULT

(繼承來源 ExternalException)
HelpLink

取得或設定與這個例外狀況相關聯的說明檔連結。

(繼承來源 Exception)
HResult

取得或設定 HRESULT,它是指派給特定例外狀況的編碼數值。

(繼承來源 Exception)
InnerException

取得造成目前例外狀況的 Exception 執行個體。

(繼承來源 Exception)
Message

取得一個描述訊息佇列錯誤的值。

MessageQueueErrorCode

取得值,指出與這個例外狀況關聯的錯誤碼。

Source

取得或設定造成錯誤的應用程式或物件的名稱。

(繼承來源 Exception)
StackTrace

取得呼叫堆疊上即時運算框架的字串表示。

(繼承來源 Exception)
TargetSite

取得擲回目前例外狀況的方法。

(繼承來源 Exception)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetBaseException()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 Exception

(繼承來源 Exception)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetObjectData(SerializationInfo, StreamingContext)

以序列化 MessageQueueException 所需的資料,填入序列化資訊物件。

GetType()

取得目前執行個體的執行階段類型。

(繼承來源 Exception)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回字串,其中包含錯誤的 HRESULT。

(繼承來源 ExternalException)

事件

SerializeObjectState
已淘汰.

當例外狀況序列化,以建立包含例外狀況相關序列化資料的例外狀況狀態物件時,就會發生此事件。

(繼承來源 Exception)

適用於

另請參閱