错误5:访问启动Windows服务时被拒绝 [英] Error 5 : Access Denied when starting windows service

查看:625
本文介绍了错误5:访问启动Windows服务时被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的错误,当我尝试启动Windows服务:

I have this error when I try to start a windows service :

而code是:

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;
}

更新#2: 服务不能启动。 System.InvalidOperationException:服务RightAccessManagementWcf.RightAccessWcf有零应用(非基础结构)终结点。这可能是因为没有配置文件找到您的应用程序,或者是因为没有服务元素相匹配的服务名称可以在配置文件中找到,或者因为没有终点的服务元素定义。    在System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription介绍)    在System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription介绍,ServiceHostBase的ServiceHost)    在System.ServiceModel.ServiceHostBase.InitializeRuntime()    在System.ServiceModel.ServiceHostBase.OnOpen(时间跨度超时)    在System.ServiceModel.Channels.CommunicationObject.Open(时间跨度超时)    在RightAccessHosting.RightAccessHost.OnStart(字串[] args)在C:\用户....

update #2 : 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. at System.ServiceModel.Description.DispatcherBuilder.EnsureThereAreNonMexEndpoints(ServiceDescription description) at System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) at System.ServiceModel.ServiceHostBase.InitializeRuntime() at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at RightAccessHosting.RightAccessHost.OnStart(String[] args) in C:\Users....

更新#1: 它的确定,你必须给正确的网络服务......现在我有一个另外一个问题

update #1 : it's ok you have to give right "NETWORK SERVICE" ... now I have an another problem

推荐答案

我知道这个职位是旧的,但没有明显的解决方案,我只是想扔在我如何解决这一点。

I realize this post is old, but there's no marked solution and I just wanted to throw in how I resolved this.

第一个错误5:访问被拒绝错误是由到输出目录到网络服务帐户赋予的权限解决

The first Error 5: Access Denied error was resolved by giving permissions to the output directory to the NETWORK SERVICE account.

第二个开始,然后停止的错误似乎是一个通用的消息时一些故障的服务。检查事件查看器(特别是应用程序日志)为真正的错误消息。

The second "started then stopped" error seems to be a generic message when something faulted the service. Check the Event Viewer (specifically the Application Log) for the real error message.

在我的情况下,它是在app.config中一个糟糕的服务配置设置。

In my case, it was a bad service configuration setting in app.config.

这篇关于错误5:访问启动Windows服务时被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆