我正在尝试从同一个IIS网络应用程序托管两个端点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