MessageQueueException 類別

定義

發生 Microsoft Message Queuing 內部錯誤時,所擲回的例外狀況。The exception that is thrown if a Microsoft Message Queuing internal error occurs.

public ref class MessageQueueException : System::Runtime::InteropServices::ExternalException
[System.Serializable]
public class MessageQueueException : System.Runtime.InteropServices.ExternalException
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類別相關聯的例外狀況是由訊息佇列內的內部錯誤所產生, 而這些錯誤應透過您的程式碼處理。Exceptions associated with the MessageQueueException class are generated by internal errors within Message Queuing that should be dealt with through your code.

每個例外狀況都是由錯誤碼和描述錯誤來源的文字字串所組成。Every exception consists of an error code and a text string that describes the source of the error. 如需這些錯誤碼的清單及其說明, 請參閱類別。MessageQueueErrorCodeSee the MessageQueueErrorCode class for a list of these error codes and their descriptions.

如果 MessageQueue 開啟一個佇列,而佇列中帶有設定為 true 的 sharedModeDenyReceive 參數,則後續嘗試從佇列讀取的任何 MessageQueue 都會因為共用違規的緣故,產生 MessageQueueException 例外狀況。If a MessageQueue opens a queue with the sharedModeDenyReceive parameter set to true, any MessageQueue that subsequently tries to read from the queue generates a MessageQueueException exception because of a sharing violation. 如果 MessageQueue 在獨佔模式中嘗試存取該佇列,而另一個 MessageQueue 已擁有該佇列的非獨佔存取,就會擲回相同的例外狀況。The same exception is thrown if a MessageQueue tries to access the queue in exclusive mode while another MessageQueue already has nonexclusive access to the queue.

不支援警示標記!!!!alert tag is not supported!!!!
MessageQueueTransaction為執行緒-單元感知。MessageQueueTransaction is threading-apartment-aware. Visual Basic 會將主執行緒的狀態設定為STA, 因此您必須MTAThreadAttributeMain副程式中套用。Visual Basic sets the state of the main thread to STA, so you must apply the MTAThreadAttribute in the Main subroutine. 否則,使用其他執行緒傳送異動式訊息時,會擲回 MessageQueueException 例外狀況。Otherwise, sending a transactional message using another thread throws a MessageQueueException exception.

建構函式

MessageQueueException(SerializationInfo, StreamingContext)

使用序列化資料,初始化 MessageQueueException 類別的新執行個體。Initializes a new instance of the MessageQueueException class with serialized data.

屬性

Data

取得提供例外狀況之其他使用者定義相關資訊的索引鍵/值組集合。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(繼承來源 Exception)
ErrorCode

取得錯誤的 HRESULTGets the HRESULT of the error.

(繼承來源 ExternalException)
HelpLink

取得或設定與這個例外狀況相關聯的說明檔連結。Gets or sets a link to the help file associated with this exception.

(繼承來源 Exception)
HResult

取得或設定 HRESULT,它是指派給特定例外狀況的編碼數值。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(繼承來源 Exception)
InnerException

取得造成目前例外狀況的 Exception 執行個體。Gets the Exception instance that caused the current exception.

(繼承來源 Exception)
Message

取得一個描述訊息佇列錯誤的值。Gets a value that describes the Message Queuing error.

MessageQueueErrorCode

取得值,指出與這個例外狀況關聯的錯誤碼。Gets a value that indicates the error code associated with this exception.

Source

取得或設定造成錯誤的應用程式或物件的名稱。Gets or sets the name of the application or the object that causes the error.

(繼承來源 Exception)
StackTrace

取得呼叫堆疊上即時運算框架的字串表示。Gets a string representation of the immediate frames on the call stack.

(繼承來源 Exception)
TargetSite

取得擲回目前例外狀況的方法。Gets the method that throws the current exception.

(繼承來源 Exception)

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetBaseException()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(繼承來源 Exception)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

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

以序列化 MessageQueueException 所需的資料,填入序列化資訊物件。Populates a serialization information object with the data needed to serialize the MessageQueueException.

GetType()

取得目前執行個體的執行階段類型。Gets the runtime type of the current instance.

(繼承來源 Exception)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回字串,其中包含錯誤的 HRESULT。Returns a string that contains the HRESULT of the error.

(繼承來源 ExternalException)

事件

SerializeObjectState

當例外狀況序列化,以建立包含例外狀況相關序列化資料的例外狀況狀態物件時,就會發生此事件。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(繼承來源 Exception)

適用於

另請參閱