日期:2014-05-17  浏览次数:21017 次

WCF学习中碰到的问题
小弟初学WCF,看书上一段代码,怎么运行都报错,代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Channels;

namespace Sender
{
    class sender
    {
        static void Main(string[] args)
        {
            try
            {
                NetTcpBinding binding = new NetTcpBinding();
                using (Message message = Message.CreateMessage(binding.MessageVersion, "sendMessage", "Message Body"))
                {
                    //创建ChannelFactory
                    IChannelFactory<IDuplexChannel> factory = binding.BuildChannelFactory<IDuplexChannel>(new BindingParameterCollection());
                    factory.Open();
                    //这里创建IRequestChannel
                    IDuplexChannel duplexChannel = factory.CreateChannel(new EndpointAddress("net.tcp://localhost:9090/DuplexService/Point2"));
                    duplexChannel.Open();
                    //发送消息
                    duplexChannel.Send(message);
                    Console.WriteLine("已经成功发送消息!");
                    duplexChannel.Close();
                    factory.Close();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.Read();
      &nbs