(三)c#整合zeroIce

来源:互联网 发布:局域网未识别的网络 编辑:程序博客网 时间:2024/06/06 23:58

vs版本: vs2015
.net: 4.5.2
语言: c#
整合参考 :https://github.com/zeroc-ice/ice-demos (或安装icegrid,通过“Source Code on GitHub”指引找到)
下载IceBuilders for visualStudio :https://zeroc.com/downloads/builders
整合后代码地址:http://download.csdn.net/download/yeness/10010388

1、Ice Builders for visual studio

  1. 双击安装IceBuilder.vsix
  2. 项目右键 -> Add Ice Builder To Project
  3. 项目右键 -> 属性 -> Ice Builder -> Referenced Assemblies: ->勾选 Ice、IceBox 、IceSSL
    这里写图片描述

2、Server端配置

*使用 iceBox,可通过配置文件启动,同时配置文件需将属性改为始终复制。
*同时复制demo中icebox/hello 下的iceboxnet.exe到项目

  • config.admin
## Proxy to the IceBox ServiceManager:#IceBoxAdmin.ServiceManager.Proxy=DemoIceBox/admin -f IceBox.ServiceManager:tcp -p 9996 -h localhost
  • config.icebox
## The IceBox ServiceManager object is provided as a facet of the Ice.Admin object.### Enable Ice.Admin object:#Ice.Admin.Endpoints=tcp -p 9996 -h localhostIce.Admin.InstanceName=DemoIceBox## The hello service##IceBox.Service.Hello=helloservice.dll:HelloServiceI --Ice.Config=config.serviceIceBox.Service.Printer=com.company.test.Server:PrinterServiceI --Ice.Config=config.service## Warn about connection exceptions#Ice.Warn.Connections=1## Network Tracing## 0 = no network tracing# 1 = trace connection establishment and closure# 2 = like 1, but more detailed# 3 = like 2, but also trace data transfer##Ice.Trace.Network=1## Protocol Tracing## 0 = no protocol tracing# 1 = trace protocol messages##Ice.Trace.Protocol=1
  • config.service
## The server creates one single object adapter with the name of the# service. The following line sets the endpoints for this adapter.# 这里注释掉ssl#Printer.Endpoints=tcp -p 10000 -h localhost:udp -p 10000 -h localhost:ssl -p 10001 -h localhostPrinter.Endpoints=tcp -p 10000 -h localhost## Warn about connection exceptions#Ice.Warn.Connections=1## Network Tracing## 0 = no network tracing# 1 = trace connection establishment and closure# 2 = like 1, but more detailed# 3 = like 2, but also trace data transfer##Ice.Trace.Network=1## Protocol Tracing## 0 = no protocol tracing# 1 = trace protocol messages##Ice.Trace.Protocol=1## SSL plug-in configuration##Ice.Plugin.IceSSL="IceSSL,Version=3.7.0.0":IceSSL.PluginFactory#IceSSL.DefaultDir=./certs#IceSSL.CAs=cacert.pem#IceSSL.CertFile=server.p12#IceSSL.Password=password

3、Client端

config.client

## The client reads this property to create the reference to the# "hello" object in the server.##Printer.Proxy=hello:tcp -h localhost -p 10000:udp -h localhost -p 10000:ssl -h localhost -p 10001Printer.Proxy=printer:tcp -p 10000 -h localhost## Warn about connection exceptions#Ice.Warn.Connections=1## Network Tracing## 0 = no network tracing# 1 = trace connection establishment and closure# 2 = like 1, but more detailed# 3 = like 2, but also trace data transfer##Ice.Trace.Network=1## Protocol Tracing## 0 = no protocol tracing# 1 = trace protocol messages##Ice.Trace.Protocol=1## SSL plug-in configuration##Ice.Plugin.IceSSL=IceSSL:IceSSL.PluginFactory#IceSSL.DefaultDir=../../../certs#IceSSL.CAs=cacert.pem#IceSSL.CertFile=client.p12#IceSSL.Password=password

client -> Programs.cs

string strCmdText;strCmdText = "/C iceboxnet --Ice.Config=config.icebox";System.Diagnostics.Process.Start("CMD.exe", strCmdText);
原创粉丝点击