【问题标题】:WCF Udp Discovery in mono单声道中的 WCF Udp 发现
【发布时间】:2014-06-04 12:23:47
【问题描述】:

我需要在我的单声道项目中启用 WCF 发现,所以我按照 this 示例来测试功能。这是我的测试代码:

Uri baseAddress = new Uri(string.Format("http://{0}:8000/calc/{1}/",
                     System.Net.Dns.GetHostName(), Guid.NewGuid().ToString()));
using (ServiceHost serviceHost = new ServiceHost(typeof(testService), baseAddress))
{
    serviceHost.AddServiceEndpoint(typeof(icalc), new WSHttpBinding(), string.Empty);
    serviceHost.Description.Behaviors.Add(new ServiceDiscoveryBehavior());
    serviceHost.AddServiceEndpoint(new UdpDiscoveryEndpoint()); //<-- Exception here
    serviceHost.Open();
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.ReadLine();
}

[ServiceContract()]
public interface icalc
{
    [OperationContract()]
    int sum(int a, int b);
}

[ServiceBehavior()]
public class testService : icalc
{
    public int sum(int a, int b)
    {
        return a + b;
    }
}

现在问题出在添加UdpDiscoveryEndpoint 的位置。我遇到了异常:

此服务中未实现合同“TargetService” '测试服务'

我尝试查看单声道源,但找不到任何解决此问题的方法。 期待任何想法如何在单声道中启用 wcf 发现或建议如何修复我的测试代码。 附:代码使用 .net 框架效果很好。

【问题讨论】:

    标签: c# mono


    【解决方案1】:

    在提出问题时,Mono 是否有 WCF 4.5 UDP 工作的可能性很小。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-24
      • 1970-01-01
      • 2014-11-04
      相关资源
      最近更新 更多