在Windows服务器上安装c#服务(拒绝访问)

本文关键字:服务 拒绝访问 安装 Windows 服务器 | 更新日期: 2023-09-27 18:03:21

创建了一个c#服务。现在我想在Windows Server 2008 R2上安装该服务。我正在使用InstallUtil命令来安装服务。我以管理员身份打开命令提示符。

服务应该作为某个用户运行,因此我在服务安装程序上将帐户设置为user。

当我运行命令时,我得到一个错误:

安装阶段出现异常:System.ComponentModel.Win32Exception: Access Denied .

日志文件如下:

Installing assembly 'C:'Service'MyService.exe'.
Affected parameters are:
   logtoconsole = 
   logfile = C:'Service'MyService.InstallLog
   assemblypath = C:'Service'MyService.exe
Rolling back assembly 'C:'Service'MyService.exe'.
Affected parameters are:
   logtoconsole = 
   logfile = C:'Service'MyService.InstallLog
   assemblypath = C:'Service'MyService.exe
An exception occurred during the Rollback phase of the System.ServiceProcess.ServiceProcessInstaller installer.
System.NullReferenceException: Object reference not set to an instance of an object.
An exception occurred during the Rollback phase of the installation. This exception will be     ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete.

下面是命令提示符显示的内容:

Beginning the Install phase of the installation.
See the contents of the log file for the C:'Service'MyService.exe assembly's progress.
The file is located at C:'Service'MyService.InstallLog.
Installing assembly 'C:'Service'MyService.exe'.
Affected parameters are:
   logtoconsole =
   logfile = C:'Service'MyService.InstallLog
   assemblypath = C:'Service'MyService.exe
An exception occurred during the Install phase.
System.ComponentModel.Win32Exception: Access Denied
   at System.ServiceProcess.ServiceProcessInstaller.OpenSecurityPolicy()
   at System.ServiceProcess.ServiceProcessInstaller.Install(IDictionary stateSaver)
   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
   at System.Configuration.Install.AssemblyInstaller.Install(IDictionary savedState)
   at System.Configuration.Install.Installer.Install(IDictionary stateSaver)
   at System.Configuration.Install.TransactedInstaller.Install(IDictionary savedState)
The Rollback phase of the installation is beginning.
See the contents of the log file for the C:'Service'MyService.exe assembly's progress.
The file is located at C:'Service'MyService.InstallLog.
Rolling back assembly 'C:'Service'MyService.exe'.
Affected parameters are:
   logtoconsole =
   logfile = C:'Service'MyService.InstallLog
   assemblypath = C:'Service'MyService.exe
An exception occurred during the Rollback phase of the System.ServiceProcess.Ser
viceProcessInstaller installer.
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
An exception occurred during the Rollback phase of the installation. This exception will be ignored and the rollback will continue. However, the machine might not fully revert to its initial state after the rollback is complete.
The Rollback phase completed successfully.
The transacted install has completed.
The installation failed, and the rollback has been performed.

有人知道我需要做什么来安装服务吗?

在Windows服务器上安装c#服务(拒绝访问)

我终于可以安装服务了。我以服务器管理员的身份登录到服务器。管理员将我的帐户添加到服务器的本地管理员组中。在这之后,我可以安装服务。它看起来像服务器管理帐户,我用来登录系统没有完全的管理权限。

谢谢你的帮助。

你确实没有提供任何关于你的服务的细节,我还不能直接评论你的帖子,但你可以试试这个链接

这个的总结是检查并确保你正在运行正确的32/64位installutil.exe,并验证你的合并模块没有引起问题。

也许更好地描述你的服务会有所帮助?服务在您的本地机器上安装得好吗?

这个问题是由于安全问题,最好在RUN AS ADMINISTRATOR中打开命令提示符并安装您的服务,它肯定会解决您的问题