简体   繁体   中英

WCF Udp Discovery in mono

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;
    }
}

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

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

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. Ps code works great using .net framework.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM