基本信息
源码名称:wcf 实现大文件上传(有进度条)实例源码
源码大小:0.09M
文件格式:.zip
开发语言:C#
更新时间:2015-01-07
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

部分win7/win8用户 运行时报错 可能是 权限问题,所以运行项目的时候 要右键>>以管理员身份运行

部分用户 运行该项目的时候 可能提示:协定需要双工 但是绑定 NetTcpBinding 不支持

这是只需要将host项目app.config中协议部分 改为wsDualHttpBinding 即可,如下代码:


      <service name="WcfUploadServiceLib.UpLoadService">
        <endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DualHttpBinding"
          contract="WcfUploadServiceLib.IUpLoadService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8890/WcfUploadService/" />
            <add baseAddress="net.tcp://localhost:8888/WcfUploadService/" />
          </baseAddresses>
        </host>
      </service>



另外使用wcf时,最好不要使用 using 因为使用using会屏蔽掉很多错误,误导用户,参考链接:http://www.codeproject.com/Tips/197531/Do-not-use-using-for-WCF-Clients

相关代码改为:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.ServiceModel;

namespace WcfUploadServiceHost
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            try
            {

                var host = new ServiceHost(typeof (WcfUploadServiceLib.UpLoadService));
                host.Open();
                Console.WriteLine("Server is opened...");
                Console.Read();

                //using (var host = new ServiceHost(typeof(WcfUploadServiceLib.UpLoadService)))
                //{
                //    host.Open();
                //    Console.WriteLine("Server is opened...");
                //    Console.Read();
                //}
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.Read();
            }
        }
    }
}