私の問題は、サーバー アプリケーション (リモート コンピューター上) を使用して、特定のイベントを複数のクライアント コンピューターに発行することです。サーバーとクライアントは.Net-Remotingを使用して通信するため、現在、リモート.Net-Eventsを使用して機能を取得しています。ただし、1 つの欠点があります。サーバー (イベント パブリッシャ) がオフラインになり、再起動すると、リモート オブジェクト参照が無効になるため、クライアントは接続を失います。
この問題を解決するために、疎結合イベントと一時的な COM サブスクリプションを調べています。1 つのパブリッシャーと 2 つのサブスクライバーで小さなデモ アプリケーションを作成しました。1台のコンピューターで美しく動作します。
COMAdmin-Libraries を使用して、イベント サブスクライバーの一時的なサブスクリプションを作成しています。コードは次のようになります。
MyEventHandler handler = new MyEventHandler();
ICOMAdminCatalog catalog;
ICatalogCollection transientCollection;
ICatalogObject subscription;
catalog = (ICOMAdminCatalog)new COMAdminCatalog();
transientCollection = (ICatalogCollection)catalog.GetCollection("TransientSubscriptions");
subscription = (ICatalogObject)transientCollection.Add();
subscription.set_Value("Name", "SubTrans");
subscription.set_Value("SubscriberInterface", handler);
string eventClassString = "{B57E128F-DB28-451b-99D3-0F81DA487EDE}";
subscription.set_Value("EventCLSID", eventClassString);
string sinkString = "{9A616A06-4F8D-4fbc-B47F-482C24A04F35}";
subscription.set_Value("InterfaceID", sinkString);
subscription.set_Value("FilterCriteria", "");
subscription.set_Value("PublisherID", "");
transientCollection.SaveChanges();
handler.Event1 += OnEvent1;
handler.Event2 += OnEvent2;
私の質問は次のとおりです。これをネットワーク経由で機能させるには、サブスクリプションで何を変更する必要がありますか? それは可能ですか?