共用方式為


InstanceContext.IncomingChannels 屬性

定義

取得連入服務執行個體的工作階段通道。

public:
 property System::Collections::Generic::ICollection<System::ServiceModel::Channels::IChannel ^> ^ IncomingChannels { System::Collections::Generic::ICollection<System::ServiceModel::Channels::IChannel ^> ^ get(); };
public System.Collections.Generic.ICollection<System.ServiceModel.Channels.IChannel> IncomingChannels { get; }
member this.IncomingChannels : System.Collections.Generic.ICollection<System.ServiceModel.Channels.IChannel>
Public ReadOnly Property IncomingChannels As ICollection(Of IChannel)

屬性值

ICollection<IChannel>

ICollection<T> 型別的 IChannel,其中包含連入服務執行個體的工作階段通道。

例外狀況

服務執行個體已關閉,無法使用。

服務執行個體處於錯誤狀態。

範例

下列程式碼說明如何存取 IncomingChannels 屬性︰

OperationContext operationContext = OperationContext.Current;
InstanceContext instanceContext = operationContext.InstanceContext;
ICollection<IChannel> incomingChannels = instanceContext.IncomingChannels;
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/service");

// Create a ServiceHost for the CalculatorService type and provide the base address.
using (ServiceHost serviceHost = new ServiceHost(typeof(CalculatorService), baseAddress))
{
    serviceHost.Open();
    OperationContext operationContext = OperationContext.Current;
    InstanceContext instanceContext = operationContext.InstanceContext;
    ICollection<IChannel> channels = instanceContext.IncomingChannels;
}

適用於