COM Interop (含 Notification Services)

所有 Notification Services API 都是利用 Managed 程式碼來開發的。不過,許多 Notification Services 類別都部署成從 Unmanaged 程式碼使用,或透過 COM Interop 來使用。如果您將 Notification Services 整合到現有的 Unmanaged 應用程式中,您的訂閱管理介面可能需要繼續使用 Unmanaged 程式碼。COM Interop 方案專用於這個用途。

不支援 COM Interop 的命名空間

下列 Notification Services 命名空間中的類別不支援 COM Interop:

  • Microsoft.SqlServer.NotificationServices.Rules,用在支援以條件為基礎之訂閱的訂閱管理介面中。這個命名空間在 Microsoft.SqlServer.NotificationServices.Rules.dll 組件中。
  • Microsoft.SqlServer.Management.Nmo,它可讓您以程式設計的方式定義 Notification Services 應用程式,以及設定、部署和管理 Notification Services 執行個體。這個命名空間在 Microsoft.SqlServer.Smo.dll 組件中。

Microsoft.SqlServer.NotificationServices 命名空間

Microsoft.SqlServer.NotificationServices 命名空間中的下列類別至少有 COM Interop 的部份支援:

這些類別提供一個預設建構函式和一個 Initialize 方法,供您在 Unmanaged 程式碼中建立和初始化物件。對於這些類別中的多載方法,最大量的多載是提供給 COM 呼叫者,方法參數是選擇性的,以便提供對等的功能。

如果您安裝了多個 Notification Services 版本,且在使用 COM Interop,您的程式碼會使用最近安裝的 Notification Services 版本的 API。這不必然是 Notification Services 的最高版本號碼。這種不一致的情況可能是因為程式識別碼 (在 HKEY_CLASSES_ROOT 之下) 的形式是 "Microsoft.SqlServer.NotificationServices.NSInstance",一律會指向最近安裝的版本。

如需有關使用 COM Interop 的詳細資訊,請參閱 Microsoft MSDN® Library 中的 <COM Interoperability in Visual Basic and Visual C#>(英文)。

請參閱

概念

Notification Services 架構
Notification Services 程式設計架構
Notification Services 部署選項

其他資源

建立 Notification 解決方案
部署 Notification Services
管理 Notification Services

說明及資訊

取得 SQL Server 2005 協助