我有一个系统托盘应用程序,它已安装并从登录脚本开始运行.
该程序在启动时失败,因为它表示服务未启动但我不知道它是哪一个.
我以为是RPC服务(name = RpcSs).这是我尝试但没有奏效:
string ServiceName_Rpc = "RpcSs";
ServiceController controller = new ServiceController(ServiceName_Rpc);
controller.WaitForStatus(ServiceControllerStatus.Running);
Run Code Online (Sandbox Code Playgroud)
服务器服务未启动.(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 context,Type principalType,Nullable
1 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.FindResultEnumerator1.get_Current()System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Linq.Enumerable.Any[TSource](IEnumerable1 source)
它说错误消息中的哪个服务:
该服务器服务未启动
服务器服务:
支持此计算机通过网络共享文件,打印和命名管道.如果停止此服务,则这些功能将不可用.如果禁用此服务,则任何明确依赖它的服务都将无法启动.
尝试更改代码以等待此服务,看看你是否有运气.虽然,我不确定你在做什么需要这项服务,所以不能保证它会起作用.