net.tcp を使用して WCF を Windows サービスとしてホストしています。サービスの開始時にWindowsサービスをインストールした後、サービスが開始および停止されたことがわかります。
サービス 'MYService' にエンドポイントを追加するには、空でないコントラクト名を指定する必要があります。System.ServiceModel.Description.ConfigLoader.LookupContract (文字列の契約名、文字列のサービス名) で
私の OnStart 関数は次のとおりです
protected override void OnStart(string[] args)
{
try
{
if (myServiceHost != null)
{
myServiceHost.Close();
}
myServiceHost = new ServiceHost(typeof(MYservice));
myServiceHost.Open();
}
catch (Exception ex)
{
log.Error("ONStart", ex);
throw;
}
}
構成ファイルは次のとおりです。
<serviceHostingEnvironment minFreeMemoryPercentageToActivateService="10" />
<services>
<service behaviorConfiguration="myServiceBehavior"
name="myNamespace.myTestService">
<endpoint binding="netTcpBinding" bindingConfiguration="netTCPBindingConfig" contract="myNamespace.ServiceInterface.ImyTestService" />
<endpoint binding="mexTcpBinding" bindingConfiguration="" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://10.1.3.69:8523/TestService" />
</baseAddresses>
<timeouts closeTimeout="10:00:10" openTimeout="10:01:00" />
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="myServiceBehavior">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>