Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
启动时运行C#程序时出现服务未启动异常_C#_Startup - Fatal编程技术网

启动时运行C#程序时出现服务未启动异常

启动时运行C#程序时出现服务未启动异常,c#,startup,C#,Startup,我有一个系统托盘应用程序,可以安装并从登录脚本开始运行 这个程序在启动时失败了,因为它说一个服务没有启动,但我不知道它是哪一个 我以为是RPC服务(name=RpcSs)。以下是我尝试过但没有成功的方法: string ServiceName_Rpc = "RpcSs"; ServiceController controller = new ServiceController(ServiceName_Rpc); controller.WaitForStatus(ServiceController

我有一个系统托盘应用程序,可以安装并从登录脚本开始运行

这个程序在启动时失败了,因为它说一个服务没有启动,但我不知道它是哪一个

我以为是RPC服务(name=RpcSs)。以下是我尝试过但没有成功的方法:

string ServiceName_Rpc = "RpcSs";
ServiceController controller = new ServiceController(ServiceName_Rpc);
controller.WaitForStatus(ServiceControllerStatus.Running);

服务器服务未启动。(来自HRESULT的异常:0x80070842)

在System.DirectoryServices.DirectoryEntry.RefreshCache()中 在System.DirectoryServices.AccountManagement.PrincipalContext.DoMachineInit()中 在System.DirectoryServices.AccountManagement.PrincipalContext.Initialize()中 在System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx()中 位于System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext上下文,键入principalType,Nullable
1 identityType,String identityValue,DateTime refDate)
位于System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext上下文,键入principalType,IdentityType IdentityType,String identityValue)
位于System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext上下文,IdentityType IdentityType,String identityValue)
在System.DirectoryServices.AccountManagement.AuthZSet.get_CurrentAsPrincipal()中
在System.DirectoryServices.AccountManagement.FindResultEnumerator中
在System.Linq.Enumerable.WhereEnumerableInterator
1.MoveNext()中
at System.Linq.Enumerable.Any[t源](IEnumerable
1源)


它会在错误消息中显示哪个服务:

服务器服务未启动

服务器服务:

支持文件、打印和命名管道 通过网络共享此文件 电脑。如果此服务停止, 这些功能将不可用。 如果此服务被禁用,则任何 明确依赖于它的服务 将无法启动


尝试更改您的代码以等待此服务,看看您是否运气好。不过,我不确定您正在做什么需要这项服务,所以不能保证它能正常工作。

谢谢您指出这一点。我没有意识到“服务器”是一种服务。我完全误解了这个信息。