共用方式為


程式設計組態

在某些情況下,程式設計組態很有用處。雖然組態檔可以幫助您快速重新導向,而不需重新編譯應用程式,您也可以在裝載的應用程式定義域與用戶端應用程式定義域中直接設定您的遠端型別。一般組態需求都適用。下列程式碼範例顯示接聽應用程式定義域的簡單程式設計組態。

ChannelServices.RegisterChannel(New HttpChannel(1234))
Dim WKSTE As New WellKnownServiceTypeEntry(GetType(ServiceClass), "HttpService", WellKnownObjectMode.SingleCall)
RemotingConfiguration.ApplicationName = "HttpService"
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE)
ChannelServices.RegisterChannel(new HttpChannel(1234));
WellKnownServiceTypeEntry WKSTE = new WellKnownServiceTypeEntry(typeof(ServiceClass),"HttpService", WellKnownObjectMode.SingleCall);
RemotingConfiguration.ApplicationName = "HttpService";
RemotingConfiguration.RegisterWellKnownServiceType(WKSTE);

在更複雜的情況中,例如使用程式設計方式來發行特定的遠端物件執行個體,然後從發行中移除該物件,則此型別的組態就是必要項。如需詳細資訊,請參閱進階遠端處理遠端處理範例:動態發行

請參閱

參考

RemotingConfiguration
ChannelServices

概念

遠端應用程式的組態

Footer image

Copyright © 2007 by Microsoft Corporation. All rights reserved.