gpt4 book ai didi

c# - 启动时运行C#程序时服务未启动异常

转载 作者:行者123 更新时间:2023-12-03 02:35:13 37 4
gpt4 key购买 nike

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

程序启动失败,因为它说服务未启动,但我不知道是哪一个。

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

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

The Server service is not started. (Exception from HRESULT: 0x80070842)

at System.DirectoryServices.DirectoryEntry.RefreshCache() at System.DirectoryServices.AccountManagement.PrincipalContext.DoMachineInit() at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx() at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable1 identityType, String identityValue, DateTime refDate)
at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue)
at System.DirectoryServices.AccountManagement.GroupPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue)
at System.DirectoryServices.AccountManagement.AuthZSet.get_CurrentAsPrincipal()
at System.DirectoryServices.AccountManagement.FindResultEnumerator
1.get_Current() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable
1 source)

最佳答案

它在错误消息中说明了哪个服务:

The Server service is not started

服务器服务:

Supports file, print, and named-pipe sharing over the network for this computer. If this service is stopped, these functions will be unavailable. If this service is disabled, any services that explicitly depend on it will fail to start.

尝试更改您的代码以等待此服务,看看您是否有运气。不过,我不确定您正在做什么需要此服务,因此不能保证它会起作用。

关于c# - 启动时运行C#程序时服务未启动异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5916545/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com