单声道 WCF Udp 发现 [英] WCF Udp Discovery in mono

查看:76
本文介绍了单声道 WCF Udp 发现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的单声道项目中启用 WCF 发现,所以我关注了this 测试功能的示例.这是我的测试代码:

I need to enable WCF discovery in my mono project so I was following this example to test feature. This is my test code:

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 添加的位置.我遇到了异常:

Now the problem is in line where is UdpDiscoveryEndpoint added. I'am getting exception:

合同TargetService"未在此服务中实现'测试服务'

Contract 'TargetService' is not implemented in this service 'testService'

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

I tried to look at mono source, but could't find any workarounds for this problem. Looking forward for any ideas how to enable wcf discovery in mono or suggestions how could I fix my test code. P.s. code works great using .net framework.

推荐答案

在提出 Mono 是否支持 WCF 4.5 UDP 的问题时非常不可能.

Very unlikely at the time of the question whether Mono had WCF 4.5 UDP working .

这篇关于单声道 WCF Udp 发现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆