我将WCF作为Windows服务使用net.tcp托管。在启动服务时安装Windows服务后,我得到该服务已启动并停止。将WCF作为Windows服务托管“服务已启动并停止”
错误说为了添加一个端点到服务'MYService',必须指定一个非空的合同名称。 在System.ServiceModel.Description.ConfigLoader.LookupContract(字符串contractName,字符串服务名)
我的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>
请发布您的WCF配置 – 2012-04-25 09:30:32
错误在您的配置文件中。此行为特定于在服务启动期间发生某种异常的情况。发布您的配置。 – paramosh 2012-04-25 09:32:27