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. UILabel 整理

      UILabel 多行文字自动换行 (自动折行) 1.UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(10, 100, 3 ...

  2. 下拉框的选择跳转事件(jqure)

    <select id="coupontype"> <option value="@CouponType.全部" href="@Url ...

  3. 超炫酷web前端的jQuery/HTML5应用搜罗

    作为前端开发者,我们肯定都使用过非常多的jQuery插件,毋庸置疑,jQuery非常流行,尤其是结合HTML5和CSS3以后,让这些jQuery插件有了更多地动画效果,更为绚丽多彩. 1.HTML5/ ...

  4. 安装PHP软件

    安装PHP软件 ① tar -zxvf php-5.2.5.tar.gz ② cd php-5.2.5 ③ 使用configure配置安装信息(最重要) ./configure \ --prefix= ...

  5. Java中的哈希

    Java中的哈希 前言 在开发中经常用到HashMap.HashSet等与哈希有关的数据结构,一直只知道这些哈希的数据结构不保证顺序,不清楚具体什么情况.所以在这里大致总结一下.   Java的Has ...

  6. 胸腺嘧啶“T”

    4.下列物质或结构中含胸腺嘧啶“T”的是( )A.DNA聚合酶 B.烟草花叶病毒C.ATP D.B淋巴细胞中的线粒体

  7. [Guava源码分析]Objects 和 ComparisonChain:帮助重写Object方法

    我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3874194.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...

  8. C语言求两个函数中的较大者的MAX函数

    //求两个函数中的较大者的MAX函数 #include <stdio.h> int main(int argc, const char * argv[]) { printf("i ...

  9. Android studio 读取properties文件

    System.out.println(Thread.currentThread().getContextClassLoader().getResource("").getPath( ...

  10. Logstash+kibana+ ElasticSearch+redis

    这是之前Logstash+kibana+ ElasticSearch+redis 安装时,自己整理的初学者容易看懂的资料,按照以下的步骤也已经完成了安装. 这里有二台服务器: 192.168.148. ...