RegistrationException 類別

定義

當偵測到註冊錯誤時,所擲回的例外狀況。

public ref class RegistrationException sealed : SystemException
[System.Serializable]
public sealed class RegistrationException : SystemException
[<System.Serializable>]
type RegistrationException = class
    inherit SystemException
Public NotInheritable Class RegistrationException
Inherits SystemException
繼承
RegistrationException
屬性

範例

下列程式代碼範例包含 catch 區塊,示範如何處理註冊例外狀況。

try
{
   String^ applicationName = "Queued Component";
   String^ typeLibraryName = nullptr;
   RegistrationHelper^ helper = gcnew RegistrationHelper;
   // Call the InstallAssembly method passing it the name of the assembly to 
   // install as a COM+ application, the COM+ application name, and 
   // the name of the type library file.
   // Setting the application name and the type library to NULL (nothing in Visual Basic .NET
   // allows you to use the COM+ application name that is given in the assembly and 
   // the default type library name. The application name in the assembly metadata 
   // takes precedence over the application name you provide to InstallAssembly. 
   helper->InstallAssembly( "C:..\\..\\QueuedComponent.dll",  applicationName,  typeLibraryName, InstallationFlags::CreateTargetApplication );
   Console::WriteLine( "Registration succeeded: Type library {0} created.", typeLibraryName );
   Console::Read();

   // Create a RegistrationConfig object and set its attributes
   // Create a RegistrationHelper object, and call the InstallAssemblyFromConfig
   // method by passing the RegistrationConfiguration object to it as a 
   // reference object
   RegistrationConfig^ registrationConfiguration = gcnew RegistrationConfig;
   registrationConfiguration->AssemblyFile = "C:..\\..\\QueuedComponent.dll";
   registrationConfiguration->Application = "MyApp";
   registrationConfiguration->InstallationFlags = InstallationFlags::CreateTargetApplication;
   RegistrationHelper^ helperFromConfig = gcnew RegistrationHelper;
   helperFromConfig->InstallAssemblyFromConfig(  registrationConfiguration );
}
catch ( RegistrationException^ e ) 
{
   Console::WriteLine( e->Message );

   // Check whether the ErrorInfo property of the RegistrationException object is null. 
   // If there is no extended error information about 
   // methods related to multiple COM+ objects ErrorInfo will be null.
   if ( e->ErrorInfo != nullptr )
   {
      // Gets an array of RegistrationErrorInfo objects describing registration errors
      array<RegistrationErrorInfo^>^ registrationErrorInfos = e->ErrorInfo;
      
      // Iterate through the array of RegistrationErrorInfo objects and disply the 
      // ErrorString for each object.
      System::Collections::IEnumerator^ myEnum = registrationErrorInfos->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         RegistrationErrorInfo^ registrationErrorInfo = (RegistrationErrorInfo^)( myEnum->Current );
         Console::WriteLine( registrationErrorInfo->ErrorString );
      }
   }
   Console::Read();
}
try
{
    string applicationName = "Queued Component";			
    string typeLibraryName = null;
    RegistrationHelper helper = new RegistrationHelper();
    // Call the InstallAssembly method passing it the name of the assembly to
    // install as a COM+ application, the COM+ application name, and
    // the name of the type library file.
    // Setting the application name and the type library to NULL (nothing in Visual Basic .NET
    // allows you to use the COM+ application name that is given in the assembly and
    // the default type library name. The application name in the assembly metadata
    // takes precedence over the application name you provide to InstallAssembly.
    helper.InstallAssembly(@"C:..\..\QueuedComponent.dll", ref applicationName, ref typeLibraryName, InstallationFlags.CreateTargetApplication);
    Console.WriteLine("Registration succeeded: Type library {0} created.", typeLibraryName);
    Console.Read();

    // Create a RegistrationConfig object and set its attributes
    // Create a RegistrationHelper object, and call the InstallAssemblyFromConfig
    // method by passing the RegistrationConfiguration object to it as a
    // reference object
    RegistrationConfig registrationConfiguration = new RegistrationConfig();
    registrationConfiguration.AssemblyFile=@"C:..\..\QueuedComponent.dll";
    registrationConfiguration.Application = "MyApp";
    registrationConfiguration.InstallationFlags = InstallationFlags.CreateTargetApplication;
    RegistrationHelper helperFromConfig = new RegistrationHelper();
    helperFromConfig.InstallAssemblyFromConfig(ref registrationConfiguration);
}

catch(RegistrationException e)
{
    Console.WriteLine(e.Message);

    // Check whether the ErrorInfo property of the RegistrationException object is null.
    // If there is no extended error information about
    // methods related to multiple COM+ objects ErrorInfo will be null.
    if(e.ErrorInfo != null)
    {
        // Gets an array of RegistrationErrorInfo objects describing registration errors
        RegistrationErrorInfo[] registrationErrorInfos = e.ErrorInfo;

        // Iterate through the array of RegistrationErrorInfo objects and disply the
        // ErrorString for each object.

        foreach (RegistrationErrorInfo registrationErrorInfo in registrationErrorInfos)
        {
            Console.WriteLine(registrationErrorInfo.ErrorString);
        }
    }
    Console.Read();
}
Try
    Dim applicationName As String = "Queued Component"
    Dim typeLibraryName As String = Nothing
    Dim helper As New RegistrationHelper

    ' Call the InstallAssembly method passing it the name of the assembly to 
    ' install as a COM+ application, the COM+ application name, and 
    ' the name of the type library file.
    ' Setting the application name and the type library to NULL (nothing in Visual Basic .NET
    ' allows you to use the COM+ application name that is given in the assembly and 
    ' the default type library name. The application name in the assembly metadata 
    ' takes precedence over the application name you provide to InstallAssembly. 
    helper.InstallAssembly("C:..\..\QueuedComponent.dll", applicationName, typeLibraryName, InstallationFlags.CreateTargetApplication)
    MsgBox("Registration succeeded: Type library " & typeLibraryName & " created.")
    Console.Read()

    ' Create a RegistrationConfig object and set its attributes
    ' Create a RegistrationHelper object, and call the InstallAssemblyFromConfig
    ' method by passing the RegistrationConfiguration object to it as a 
    ' reference object
    Dim registrationConfiguration As New RegistrationConfig()
    registrationConfiguration.AssemblyFile = "C:..\..\QueuedComponent.dll"
    registrationConfiguration.Application = "MyApp"
    registrationConfiguration.InstallationFlags = InstallationFlags.CreateTargetApplication
    Dim helperFromConfig As New RegistrationHelper()
    helperFromConfig.InstallAssemblyFromConfig(registrationConfiguration)

Catch e As RegistrationException
    MsgBox(e.Message)

    ' Check whether the ErrorInfo property of the RegistrationException object is null. 
    ' If there is no extended error information about 
    ' methods related to multiple COM+ objects ErrorInfo will be null.
    If Not (e.ErrorInfo Is Nothing) Then
        ' Gets an array of RegistrationErrorInfo objects describing registration errors
        Dim registrationErrorInfos As RegistrationErrorInfo() = e.ErrorInfo

        ' Iterate through the array of RegistrationErrorInfo objects and disply the 
        ' ErrorString for each object.
        Dim registrationErrorInfo As RegistrationErrorInfo
        For Each registrationErrorInfo In registrationErrorInfos
            MsgBox(registrationErrorInfo.ErrorString)
        Next registrationErrorInfo
    End If
    Console.Read()
End Try

建構函式

RegistrationException()

初始化 RegistrationException 類別的新執行個體。

RegistrationException(String)

使用指定的錯誤訊息,初始化 RegistrationException 類別的新執行個體。

RegistrationException(String, Exception)

使用指定的錯誤訊息和巢狀例外狀況,初始化 RegistrationException 類別的新執行個體。

屬性

Data

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

(繼承來源 Exception)
ErrorInfo

取得 RegistrationErrorInfo 物件的陣列,其描述註冊錯誤。

HelpLink

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

(繼承來源 Exception)
HResult

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

(繼承來源 Exception)
InnerException

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

(繼承來源 Exception)
Message

取得描述目前例外狀況的訊息。

(繼承來源 Exception)
Source

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

(繼承來源 Exception)
StackTrace

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

(繼承來源 Exception)
TargetSite

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

(繼承來源 Exception)

方法

Equals(Object)

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

(繼承來源 Object)
GetBaseException()

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

(繼承來源 Exception)
GetHashCode()

做為預設雜湊函式。

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

使用 RegistrationErrorInfo 中的錯誤資訊設定 SerializationInfo 物件。

GetType()

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

(繼承來源 Exception)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

建立並傳回目前例外狀況的字串表示。

(繼承來源 Exception)

事件

SerializeObjectState
已淘汰.

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

(繼承來源 Exception)

適用於