【WCF--初入江湖】13 实战
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 实战的更多相关文章
- 13 | 实战:单机如何实现管理百万主机的心跳服务? https://time.geekbang.org/column/article/240656
13 | 实战:单机如何实现管理百万主机的心跳服务? https://time.geekbang.org/column/article/240656
- [WCF编程]13.并发:服务并发模式
一.概述 传入的客户端调用消息会分发给Windows I/O线程池(线程默认为1000)上的服务实例.多个客户端可以发起多个并发的调用,并且服务可以在多个线程上处理这些请求.如果传入的调用分发给同一个 ...
- WCF初探-13:WCF客户端为双工服务创建回调对象
前言: 在WCF初探-5:WCF消息交换模式之双工通讯(Duplex)博文中,我讲解了双工通信服务的一个应用场景,即订阅和发布模式,这一篇,我将通过一个消息发送的例子讲解一下WCF客户端如何为双工服务 ...
- Apache JMeter2.13 实战
安装目录下 设置浏览器代理127.0.0.1 8080,以chrome为例 开始录制脚本,进入应用点击相应的功能,可以捕获到如下地址 去除无用地址,保留需要测试的地址 注:上图编号列表中11为获取co ...
- 13.实战交付一套dubbo微服务到k8s集群(6)之交付dubbo服务的消费者集群到K8S
构建dubbo-demo-consumer,可以使用和dubbo-demo-service的流水线来构建 1.登录jenkins构建dubbo-demo-consumer 2.填写构建dubbo-d ...
- WCF初探文章列表
WCF初探-1:认识WCF WCF初探-6:WCF服务配置 WCF初探-2:手动实现WCF程序 WCF初探-7:WCF服务配置工具使用 WCF初探-3:WCF消息交换模式之单向模式 WCF初探-8:W ...
- WCF初探-14:WCF服务协定
前言: 在前面的文章中,我们定义的服务协定上都会有一个ServiceContract的特性来修饰,这是因为服务契约的实现要靠ServiceContractAttribute 属性定义,然后使用一个或多 ...
- WCF初探-15:WCF操作协定
前言: 在前面的文章中,我们定义服务协定时,在它的操作方法上都会加上OperationContract特性,此特性属于OperationContractAttribute 类,将OperationCo ...
- 基于MSMQ绑定的WCF服务实现总结
一. 创建消息队列 1 1) 创建一个非事物性的私有队列 1 2)设置消息队列访问权限 2 二.创建WCF服务并绑定消息队列 4 1)创建HelloService服务 4 ...
随机推荐
- linux交叉编译裁剪内核记录
刚开始学习嵌入式内核编译,因为要修改内核的默认配置,因此这里把自己的学习记录写下来,方便以后查阅,也给别人一个参考,有什么写的不对的或者更好的方法,请指正~ 开发板有usb从口,现在想要让开发板作为一 ...
- 《HTML5与CSS3基础教程》学习笔记 ——Four Day
第十六章 1. 输入和元素 电子邮件框 <input type="email"> 搜索框 <input type="search"> ...
- 查看某个模块的Tables
在SE11 中 关于table的F4 help 有一个筛选条件是Package 同时由于不同的模块放在不同的Package中 很容易根据这个条件 获得某个模块的所有Tables 亲测有效 1 ...
- webstorm 自定义代码模板
Ctrl+Shift+A查找设置live 添加代码片段Live Template 编写代码的时候 缩写+Tab 即可输出代码片段 缩写启动对应代码片段的钥匙. 描述代码片段的名字. 模板文本代码片段的 ...
- SharedPreferences的基本用法
获取SharedPreferences的两种方式: 1 调用Context对象的getSharedPreferences()方法 2 调用Activity对象的getPreferences()方法 两 ...
- UCML平台中 如何设置列表单元格中的链接失效
解决方案: 找到“a.datagrid-cell-bclink”,麻烦的是这个标记是由js动态加载的,需要等待这个加载完成:等加载完成后,删除a标记“$(“a.datagrid-cell-bclink ...
- phpStudy for Linux (lnmp+lamp一键安装包)
phpStudy Linux版&Win版同步上线 支持Apache/Nginx/Tengine/Lighttpd/IIS7/8/6 phpStudy for Linux 支持Apache/Ng ...
- ORACLE AWR 和 ASH
一.关于ASH 我们都知道,用户在 ORACLE 数据库中执行操作时,必然要创建相应的连接和会话, 其中,所有当前的会话信息都保存在动态性能视图 V$SESSION 中,通过该视图,DBA 可 以查看 ...
- oracle作业
http://blog.csdn.net/hao_ds/article/details/38382931 oracle作业各种参数的详细介绍
- macos port总结
http://stackoverflow.com/questions/733951/unable-to-download-the-source-code-of-open-source-projects ...