当我尝试启动一个我在 C # 中创建的 windows 服务时,我得到了这个错误:
至今我的守则:
private ServiceHost host = null;
public RightAccessHost()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
host = new ServiceHost(typeof(RightAccessWcf));
host.Open();
}
protected override void OnStop()
{
if (host != null)
host.Close();
host = null;
}
我通过授予帐户 网络服务权限解决了上面的问题,但现在我有另一个问题:
Service cannot be started. System.InvalidOperationException: Service 'RightAccessManagementWcf.RightAccessWcf' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element. 在 System.ServiceModel.Description. DispatcherBuilder. EnsureThereNonMexEndpoints (ServiceDescription 描述) 在 System.ServiceModel.Description. DispatcherBuilder.InitializeServiceHost (ServiceDescription,ServiceHostBase serviceHost) 在 System.ServiceModel.ServiceHostBase 在 System.ServiceModel.ServiceHostBase.OnOpen (TimeSpan 超时) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) 在 C: Users... 中的 RightAccessHost.OnStart (String [] args)。