create windows service base on net.pipe ,windows 服务
来源:互联网 发布:网络骰宝赌博 编辑:程序博客网 时间:2024/05/29 13:47
1.创建一个windows服务
2.添加安装程序
3.修改
4.删除自带的Proman.CS 的MAIN函数
5.修改Services,添加ServiceModel.dll
public class NotificationWindowsService : ServiceBase
{
public ServiceHost serviceHost = null;
public NotificationWindowsService()
{
ServiceName = "WCFNotificationService";
//InitializeComponent();
}
public static void Main()
{
ServiceBase.Run(new NotificationWindowsService());
}
protected override void OnStart(string[] args)
{
log4net.Config.XmlConfigurator.Configure();
if (serviceHost != null)
{
serviceHost.Close();
}
serviceHost = new ServiceHost(typeof(Matcher));
// Open the ServiceHostBase to create listeners and start
// listening for messages.
try
{
serviceHost.Open();
}
catch (Exception ex)
{
}
}
protected override void OnStop()
{
if (serviceHost != null)
{
serviceHost.Close();
serviceHost = null;
}
}
private void InitializeComponent()
{
//
// NotificationWindowsService
//
this.ServiceName = "WCFNotificationService";
}
}
6.创建Service Interface
namespace HandPickMatchServices{
[ServiceContract(Namespace = "HandPickMatchServices", ConfigurationName = "IMatcher")]
interface IMatcher
{
[OperationContract]
Task DoMatchIngredient(List<string> ingredients);
}
}
7.创建Service Instance
namespace HandPickMatchServices
{
public class Matcher : IMatcher
{
public async Task DoMatchIngredient(List<string> ingredients)
{
}
}
}
8.添加Configuration <system.serviceModel>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<system.serviceModel>
<services>
<!-- This section is optional with the new configuration model
introduced in .NET Framework 4. -->
<service name="HandPickMatchServices.Matcher" behaviorConfiguration="MatcherBehavior">
<host>
<baseAddresses>
<add baseAddress="net.pipe://localhost/notification/service" />
</baseAddresses>
</host>
<!-- this endpoint is exposed at the base address provided by host: http://localhost:8000/ServiceModelSamples/service -->
<endpoint address="" binding="netNamedPipeBinding" contract="IMatch" bindingConfiguration="Custom.WSHTTPBinding.Configuration">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<netNamedPipeBinding>
<binding name="Custom.WSHTTPBinding.Configuration" transferMode="Streamed" maxBufferPoolSize="4194304" maxReceivedMessageSize="9223372036854775807">
<security mode="None" />
</binding>
</netNamedPipeBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MatcherBehavior">
<serviceMetadata httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
add reference
net.pipe://localhost/crawler/service/mex
install service\
1.
输入 cd C:\Windows\Microsoft.NET\Framework\v4.0.30319 回车
切换当前目录,此处需要注意的是,在C:\Windows\Microsoft.NET\Framework目录下有很多类似版本,具体去哪个目录要看项目的运行环境,例 如果是.net framework2.0则需要输入 cd C:\Windows\Microsoft.NET\Framework\v2.0.50727
2.
Install:
InstallUtil.exe E:\TestApp\Winform\WinServiceTest\WinServiceTest\bin\Debug\WinServiceTest.exe
uninstall:
InstallUtil.exe /u E:\TestApp\Winform\WinServiceTest\WinServiceTest\bin\Debug\WinServiceTest.exe
http://www.cnblogs.com/sorex/archive/2012/05/16/2502001.html
- create windows service base on net.pipe ,windows 服务
- windows create mysql service
- windows create service
- Create ASM on windows
- .net/vs2005/c# 创建windows service/windows服务
- Windows 7 Create Subversion service
- Mysql "Cannot create windows service for mysql.error:0" 安装删除windows服务
- 创建windows 服务 (windows service)
- windows pipe
- C#windows service服务
- C# 创建Windows Service服务 Windows服务
- .net中的windows service与调服务操作
- .Net Remoting的双向通信和Windows Service的宿主服务
- .Net Remoting的双向通信和Windows Service的宿主服务
- .Net Remoting的双向通信和Windows Service的宿主服务
- .net 开发 Windows Service
- jenkins-slave service on windows
- Windows Base
- Java中equals和==的区别
- (4.1.10) ImageView图片自适应
- Android 中的 requestWindowFeature
- 工作中常用到的linux命令二 c++系统环境配置 动态库文件路径的加载
- Hadoop archives 说明
- create windows service base on net.pipe ,windows 服务
- Css实现元素的垂直居中
- boost 线程同步速记
- (4.1.11)listview setOnItemClickListener 失效问题
- 微信支付V3版本JAVA版本js调用微信支付趟坑路线图
- js 字符串替换replace()详解
- AsyncTask和Handler的解析
- 通过Amazon EC2建立自己的PPTP VPN服务器
- 2011Android技术面试整理附有详细答案(包括百度、新浪、中科软等多家公司笔试面试题)