【发布时间】:2011-05-15 02:26:08
【问题描述】:
当我尝试启动我在 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;
}
更新 #1
我通过授予帐户 NETWORK SERVICE 权限解决了上述问题,但现在我遇到了另一个问题:
更新 #2
服务无法启动。 System.InvalidOperationException:服务“RightAccessManagementWcf.RightAccessWcf”的应用程序(非基础设施)端点为零。这可能是因为没有为您的应用程序找到配置文件,或者因为在配置文件中找不到与服务名称匹配的服务元素,或者因为在服务元素中没有定义端点。 在 System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription 描述) 在 System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription 描述,ServiceHostBase 服务主机) 在 System.ServiceModel.ServiceHostBase.InitializeRuntime() 在 System.ServiceModel.ServiceHostBase.OnOpen(时间跨度超时) 在 System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时) 在 C:\Users 中的 RightAccessHosting.RightAccessHost.OnStart(String[] args)....
【问题讨论】:
-
您的第二个问题并不容易仅从该消息中解决。您需要查看事件日志,看看真正的错误是什么。
-
检查系统帐户是否可以访问该文件夹。
标签: c# .net wcf windows-services