c# - .net 核心中的 WCF (TransportWithMessageCredential)

标签 c# .net wcf asp.net-core .net-core

当我尝试在 dotnet core 2.0 中创建到 WCF 客户端的连接时,我收到平台不支持的错误:

System.PlatformNotSupportedException: 'The value 'TransportWithMessageCredential' is not supported in this context for the binding security property 'securityMode'.'

如果我删除 BasicHttpSecurityMode,我会收到一个参数异常: System.ArgumentException: '提供的 URI 方案 'https' 无效;预期为“http”。

代码:

ChannelFactory<BlackBoxContract> factory = null;
BlackBoxContract serviceProxy = null;
Binding binding = null;

binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);

factory = new ChannelFactory<BlackBoxContract>(binding, new EndpointAddress("https:......."));;
serviceProxy = factory.CreateChannel();

有人找到了解决方法,因为这可能在长期路线图上吗? https://github.com/dotnet/wcf/issues/8

最佳答案

这已被最新的软件包修复。

  <ItemGroup>
    <PackageReference Include="System.ServiceModel.Duplex" Version="4.6.0" />
    <PackageReference Include="System.ServiceModel.Http" Version="4.6.0" />
    <PackageReference Include="System.ServiceModel.NetTcp" Version="4.6.0" />
    <PackageReference Include="System.ServiceModel.Security" Version="4.6.0" />
  </ItemGroup>  

关于c# - .net 核心中的 WCF (TransportWithMessageCredential),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45567598/

相关文章:

c# - 无法在不崩溃的情况下从 ComboBox 中删除项目

c# - Azure 不支持外语文件格式名称下载

c# - CallerMemberNameAttribute 和 Roslyn

c# - 无法在泛型类型之间进行转换

c# - ClosedXML 解析数字中的逗号

c# - 错误无法将类型'string'隐式转换为'int'-ForEach循环中的迭代器

c# - 从 AJAX 结果呈现 HTML 内容

C# .NET 3.5 在使用基本示例时不复制流

c# - 如何使用证书保护 3 跳 WCF 门面服务?

c# - 动态装配解析/管理