带有 .net 4.7 的 WCF 服务器和带有 .net 6.0 的客户端 - 协议错误

问题描述 投票:0回答:1

我目前正在尝试扩展一个 WCF 仅适用于 Windows 的程序,以使其在 Linux 上可行。因此,我需要将 WCF 后端通信移植到 .net 6.0。我建立这样的服务器连接:

public static IService Connect(ServerCredential credentials, IServiceCallback callback)
{
    var binding = new NetHttpBinding(BasicHttpSecurityMode.None, true)
    {
        WebSocketSettings =
        {
            TransportUsage = WebSocketTransportUsage.Always
        },
        ReaderQuotas =
        {
            MaxDepth = int.MaxValue,
            MaxArrayLength = int.MaxValue,
            MaxBytesPerRead = int.MaxValue
        },
        MaxReceivedMessageSize = 2147483647L,
        SendTimeout = TimeSpan.FromMinutes(20.0),
        ReceiveTimeout = TimeSpan.FromSeconds(2.0),
        OpenTimeout = TimeSpan.FromSeconds(2.0),
        CloseTimeout = TimeSpan.FromSeconds(2.0)
    };

    var instanceContext = new InstanceContext(callback);

    var factory = new DuplexChannelFactory<IService>(
        instanceContext,
        binding,
        new EndpointAddress(credentials.Domain));

    var channel = factory.CreateChannel();

    channel.Authenticate(credentials.User, credentials.Password); // <- error

    return channel;
}

错误信息:

System.ServiceModel.ProtocolException: '远程端点请求的确认地址与应用程序消息的地址不同。频道无法打开,因为不支持。

我在 .net 4.7 应用程序中尝试了相同的代码并且它有效。 (当然还有其他使用命名空间和其他语法的)

我的问题是现在。如果 WCF 客户端在 .net 6 上并且服务器在 .net 4.7.

上,甚至有可能完成与客户端的服务器连接

是的。我知道。 WCF 被贬低了,但在其中开发不是我的想法.. 感谢您的时间! :)

.net wcf wcf-binding duplex-channel protocolexception
1个回答
0
投票

wcf 在.NET 6.0 中不能直接使用。您需要将 wcf 代码迁移到 CoreWCF 或考虑使用 gRPC.

© www.soinside.com 2019 - 2024. All rights reserved.