WCF命名管道小例子, [英] WCF named pipe minimal example

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

问题描述

我要找的WCF命名管道的小例子(我人希望两个最小的应用程序,服务器和客户端,可以通过命名管道通信。)

I'm looking for minimal example of WCF Named Pipes (I expect two minimal applications, server and client, which can communicate via a named pipe.)

微软有璀璨的文章的 入门教程 的描述WCF通过HTTP,和我正在寻找有关WCF和命名管道类似的东西。

Microsoft has the briliant article Getting Started Tutorial that describes WCF via HTTP, and I'm looking for something similar about WCF and named pipes.

我发现在互联网上的几个职位,但他们都有点高级。我需要的东西很少,唯一的强制性功能,所以我可以加我的code和获取应用程序的工作。

I've found several posts in the Internet, but they are a little bit "advanced". I need something minimal, only mandatory functionality, so I can add my code and get the application working.

我如何更换使用命名管道?

How do I replace that to use a named pipe?

<endpoint address="http://localhost:8000/ServiceModelSamples/Service/CalculatorService"
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ICalculator"
    contract="ICalculator" name="WSHttpBinding_ICalculator">
    <identity>
        <userPrincipalName value="OlegPc\Oleg" />
    </identity>
</endpoint>

我如何更换使用命名管道?

How do I replace that to use a named pipe?

// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");

// Step 2 of the hosting procedure: Create ServiceHost
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);

try
{
    // Step 3 of the hosting procedure: Add a service endpoint.
    selfHost.AddServiceEndpoint(
        typeof(ICalculator),
        new WSHttpBinding(),
        "CalculatorService");

    // Step 4 of the hosting procedure: Enable metadata exchange.
    ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
    smb.HttpGetEnabled = true;
    selfHost.Description.Behaviors.Add(smb);

    // Step 5 of the hosting procedure: Start (and then stop) the service.
    selfHost.Open();
    Console.WriteLine("The service is ready.");
    Console.WriteLine("Press <ENTER> to terminate service.");
    Console.WriteLine();
    Console.ReadLine();

    // Close the ServiceHostBase to shutdown the service.
    selfHost.Close();
}
catch (CommunicationException ce)
{
    Console.WriteLine("An exception occurred: {0}", ce.Message);
    selfHost.Abort();
}

如何生成客户端使用命名管道?

How do I generate a client to use a named pipe?

推荐答案

我刚刚发现的这个优秀的小教程断开链接的(<一个href=\"https://web.archive.org/web/20141027055124/http://tech.pro/tutorial/855/wcf-tutorial-basic-interprocess-communication\">Cached版本)

我也跟着微软的教程,这是很好的,但我只需要管为好。

I also followed Microsoft's tutorial which is nice, but I only needed pipes as well.

正如你所看到的,你并不需要的配置文件和所有杂乱的东西。

As you can see, you don't need configuration files and all that messy stuff.

顺便说一句,他使用HTTP和管道。只是删除涉及HTTP所有code线,你会得到一个纯管道的例子。

By the way, he uses both HTTP and pipes. Just remove all code lines related to HTTP, and you'll get a pure pipe example.

这篇关于WCF命名管道小例子,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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