我创建了一个C#服务。现在我想在Windows Server 2008 R2上安装该服务。 我正在使用InstallUtil命令来安装该服务。我以管理员身份打开命令提示符。在Windows Server上安装C#服务(拒绝访问)
该服务应该以特定用户身份运行,因此我将该帐户设置为Service Installer上的用户。
当我运行命令我得到一个错误: 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.
是否有人知道我需要做安装服务?
你有isntaller自定义代码吗? – 2013-03-11 10:02:41
安装程序中没有自定义代码。 – Alexander 2013-03-11 10:04:56
我现在在Visual Studio中创建了一个新的空服务项目,并试图在服务器上安装该服务。我得到了同样的错误。 – Alexander 2013-03-11 10:11:43