1、wcf接口和实现类
2、安装、启动、停止、卸载服务窗体和后台代码,WinServerManager类
3、wcf服务添加步骤:
1、添加wiondows窗体
2、右键类库,添加windows服务。
3、双击打开服务文件,右键添加安装程序,修改ServiceInstaller文件中,name属性改为ServiceName属性值。修改serviceProcessInstaller1文件中,Account属性由user改为LocalSystem。
4、修改Program.cs,添加
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new ServiceLed()
};
ServiceBase.Run(ServicesToRun);
}
5、修改App.config,改为
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- 部署服务库项目时,必须将配置文件的内容添加到
主机的 app.config 文件中。System.Configuration 不支持库的配置文件。 -->
<system.serviceModel>
<services>
<service name="IBLL.LedService">
<endpoint address="" binding="basicHttpBinding" contract="IBLL.ILedService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://127.0.0.1:8733/LedService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- 为避免泄漏元数据信息,
请在部署前将以下值设置为 false -->
<serviceMetadata httpGetEnabled="True"/>
<!-- 要接收故障异常详细信息以进行调试,
请将以下值设置为 true。在部署前设置为 false
以避免泄漏异常信息 -->
<serviceDebug includeExceptionDetailInFaults="True" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
6、修改Properties属性,输出路径,改为启动服务类库的debug文件夹所在路径。
大功告成!