C# 如何获取WCF的协议映射列表?
我想知道是否有人知道如何获取WCF的协议映射列表(类似于ServiceHost.AddDefaultEndpoints函数本身所做的),而不管映射来自何处(machine.config、app.config、web.config等)?我找到了解决方案。我在这里为其他人分享:C# 如何获取WCF的协议映射列表?,c#,.net,vb.net,wcf,C#,.net,Vb.net,Wcf,我想知道是否有人知道如何获取WCF的协议映射列表(类似于ServiceHost.AddDefaultEndpoints函数本身所做的),而不管映射来自何处(machine.config、app.config、web.config等)?我找到了解决方案。我在这里为其他人分享: Dim pms As ProtocolMappingSection = CType(ConfigurationManager.GetSection("system.serviceModel/protocolMapping")
Dim pms As ProtocolMappingSection = CType(ConfigurationManager.GetSection("system.serviceModel/protocolMapping"), ProtocolMappingSection)
Dim pmc As ProtocolMappingElementCollection = pms.ProtocolMappingCollection
For Each pme As ProtocolMappingElement In pmc
If String.Compare(pme.Scheme, uri.Scheme, True) = 0 Then
' Do something
Exit For
End If
Next