0

我正在尝试从同一个 IIS Web 应用程序托管两个端点,Net.Tcp 和 wsHTTP,但似乎无法让它工作。当我只托管一个 Net.Tcp 端点时,它工作正常。将 HTTP 添加到主机后,我立即收到以下错误:“此参数的值必须为正。参数名称:maxAccepts 实际值为 0”

任何人都知道这是对 IIS 7 的限制还是我做错了什么?我所做的是扩展 ServiceHostFactory 类并覆盖 CreateServiceHost 方法。这是代码的亮点:

Public Class QLHostFactory
Inherits ServiceHostFactory

Protected Overloads Overrides Function CreateServiceHost(ByVal svcTyp As Type, ByVal baseAddresses() As Uri) As ServiceHost
    Dim QLSvcHost As ServiceHost = Nothing

    Dim ntcpUri() As Uri = Nothing
    ' I have to filter out all other uri and leave only nettcp in the 
    ' list to get it to work. But what I really want is to allow http in here too.
    For Each u As Uri In baseAddresses
        If u.Scheme = Uri.UriSchemeNetTcp Then
            ReDim ntcpUri(0)
            ntcpUri(0) = u
            Exit For
        End If
    Next
    QLSvcHost = New ServiceHost(svcTyp, ntcpUri)
    SetHost(QLSvcHost, svcTyp) ' <== set endpoints for each baseaddresses, etc.
    Return QLSvcHost
End Function
4

0 回答 0