13 实战

在线升级

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.IO;
using System.Reflection;
namespace load
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} //进入
private void button1_Click(object sender, EventArgs e)
{
//下载客户端程序
NetTcpBinding bind = new NetTcpBinding();
bind.MaxReceivedMessageSize = ;
bind.ReaderQuotas.MaxArrayLength = ;
bind.ReaderQuotas.MaxStringContentLength = ; EndpointAddress address = new EndpointAddress("net.tcp://localhost:5400/sell");
ChannelFactory<Contracts.ISellOpration> factory = new ChannelFactory<Contracts.ISellOpration>(bind, address);
byte[] bt = factory.CreateChannel().download(); //把bt转成dll文件
FileStream stream = new FileStream(Application.StartupPath + "/winClient.dll", FileMode.Create);
stream.Write(bt, , bt.Length);
stream.Close();
factory.Close(); //启动客户端程序(dll)
Assembly ass = Assembly.LoadFile(Application.StartupPath + "/winClient.dll");
Type tp = ass.GetType("winClient.frmMain");
Form frm = (Form)Activator.CreateInstance(tp);
frm.Show();
}
}
}

ISellOpration.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Contracts
{ [ServiceContract]
public interface ISellOpration
{
//商品进货
[OperationContract]
int addstockBill(Bill bill); //商品销售
[OperationContract]
int addSellBill(Bill bill); //下载新版本的客户应用程序
[OperationContract]
byte[] download();
}
}

ServiceOpration.cs

    public class ServiceOpration:Contracts.ISellOpration
{
.............. //下载客户端
public byte[] download()
{
FileStream stream = new FileStream(Application.StartupPath+"/winClient.dll", FileMode.Open, FileAccess.Read);
byte[] bt = new byte[stream.Length];
stream.Read(bt, , bt.Length);
stream.Close();
return bt;
}

  winClient.dll是把WinForm项目的参数类型从“Window应用程序”改成“类库”。

其中

public partial class frmMain : Form

【WCF--初入江湖】13 实战的更多相关文章

  1. 13 | 实战:单机如何实现管理百万主机的心跳服务? https://time.geekbang.org/column/article/240656

    13 | 实战:单机如何实现管理百万主机的心跳服务? https://time.geekbang.org/column/article/240656

  2. [WCF编程]13.并发:服务并发模式

    一.概述 传入的客户端调用消息会分发给Windows I/O线程池(线程默认为1000)上的服务实例.多个客户端可以发起多个并发的调用,并且服务可以在多个线程上处理这些请求.如果传入的调用分发给同一个 ...

  3. WCF初探-13:WCF客户端为双工服务创建回调对象

    前言: 在WCF初探-5:WCF消息交换模式之双工通讯(Duplex)博文中,我讲解了双工通信服务的一个应用场景,即订阅和发布模式,这一篇,我将通过一个消息发送的例子讲解一下WCF客户端如何为双工服务 ...

  4. Apache JMeter2.13 实战

    安装目录下 设置浏览器代理127.0.0.1 8080,以chrome为例 开始录制脚本,进入应用点击相应的功能,可以捕获到如下地址 去除无用地址,保留需要测试的地址 注:上图编号列表中11为获取co ...

  5. 13.实战交付一套dubbo微服务到k8s集群(6)之交付dubbo服务的消费者集群到K8S

    构建dubbo-demo-consumer,可以使用和dubbo-demo-service的流水线来构建 1.登录jenkins构建dubbo-demo-consumer  2.填写构建dubbo-d ...

  6. WCF初探文章列表

    WCF初探-1:认识WCF WCF初探-6:WCF服务配置 WCF初探-2:手动实现WCF程序 WCF初探-7:WCF服务配置工具使用 WCF初探-3:WCF消息交换模式之单向模式 WCF初探-8:W ...

  7. WCF初探-14:WCF服务协定

    前言: 在前面的文章中,我们定义的服务协定上都会有一个ServiceContract的特性来修饰,这是因为服务契约的实现要靠ServiceContractAttribute 属性定义,然后使用一个或多 ...

  8. WCF初探-15:WCF操作协定

    前言: 在前面的文章中,我们定义服务协定时,在它的操作方法上都会加上OperationContract特性,此特性属于OperationContractAttribute 类,将OperationCo ...

  9. 基于MSMQ绑定的WCF服务实现总结

    一. 创建消息队列    1 1) 创建一个非事物性的私有队列    1 2)设置消息队列访问权限    2 二.创建WCF服务并绑定消息队列    4 1)创建HelloService服务    4 ...

随机推荐

  1. System.Data.Entity.Internal.AppConfig 类型初始值设定项引发异常

    在一开始时将connectionStrings 写在了configSections之上如下图一示,结果抛出:“System.Data.Entity.Internal.AppConfig”的类型初始值设 ...

  2. libjpeg 交叉编译动态库和静态库

    1.下载libjpeg库,解压之     得到了jpeg6b和libtool-2.2.4两个文件夹. 2.编译安装libtool工具.   这是配置libtool,这里需要注意:configure 参 ...

  3. 9款完美体验的HTML5/jQuery应用

    1.jQuery动画图标菜单导航 仿苹果样式 这次要分享的这款jQuery插件非常酷,它是一款带有动画按钮的jQuery菜单插件.而且从菜单的外观上来看,有点苹果菜单风格的味道.当我们将鼠标滑过菜单项 ...

  4. 南阳理工ACM975--关于521

    http://acm.nyist.net/JudgeOnline/problem.php?pid=975 这是我的源码.一直超时,一直超时. 还有itoa函数函数的使用.可以改成sprintf(str ...

  5. Linux学习笔记之VI(VIM)编辑器

    百度关于vi的资料 http://baike.baidu.com/view/908054.htm 关于vi 和vim的介绍可以在上面的网址看到. 1   进入和退出vi 进入:在终端命令行输入 vi ...

  6. Visual Studio 2013密钥

    Visual Studio 2013旗舰版KEY:BWG7X-J98B3-W34RT-33B3R-JVYW9Ultimate:BWG7X-J98B3-W34RT-33B3R-JVYW9 Premium ...

  7. JS input文本框禁用右键和复制粘贴功能的代码

    代码如下: function click(e) { if (document.all) { ||||) { oncontextmenu='return false'; } } if (document ...

  8. ASP.ENT Core Linux 下 为 donet创建守护进程(转载)

    原文地址:http://www.cnblogs.com/savorboard/p/dotnetcore-supervisor.html 前言 在上篇文章中介绍了如何在 Docker 容器中部署我们的 ...

  9. 虚拟局域网VLAN

    6.5.1配置路由器广域网端口的PPP封装 (1)配置路由器A: Router>enable Router#config Router_config#hostname Router-A Rout ...

  10. Oracle 表的访问方式(1) ---全表扫描、通过ROWID访问表

    1.Oracle访问表的方式 全表扫描.通过ROWID访问表.索引扫描 2.全表扫描(Full Table Scans, FTS) 为实现全表扫描,Oracle顺序地访问表中每条记录,并检查每一条记录 ...