我想在Windows 7 x64上安装我的Windows服务
收到此错误
An exception occurred during the Rollback phase of the System.Diagnostics.EventLogInstaller installer.
System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.
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.
这是我的MyWindowsServiceInstaller
代码:
var processInstaller = new ServiceProcessInstaller();
var serviceInstaller = new ServiceInstaller();
processInstaller.Account = ServiceAccount.LocalSystem;
serviceInstaller.DisplayName = "My Service";
serviceInstaller.StartType = ServiceStartMode.Manual;
serviceInstaller.ServiceName = "My Service";
this.Installers.Add(processInstaller);
this.Installers.Add(serviceInstaller);
我已将我的应用程序名称设置为启动项目
这是bat文件
@ECHO OFF
REM The following directory is for .NET 2.0
set DOTNETFX2=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
set PATH=%PATH%;%DOTNETFX2%
echo Installing MyService...
echo ---------------------------------------------------
InstallUtil /i ConsoleApplication5.exe
echo ---------------------------------------------------
echo Done.
pause
这项服务不仅仅是我的电脑,如果我能解决这个问题,它可以解决任何其他电脑吗?
由于
答案 0 :(得分:8)
您可以尝试以这种方式安装。 打开cmd作为管理员并找到系统中的.Net Framework路径
Eg: "C:\Windows\Microsoft.Net\Framework\v4.0.30319\"
然后在installutil.exe的帮助下,您可以安装该服务。
Eg: C:\Windows\Microsoft.Net\Framework\v4.0.30319\installutil.exe "Your service exe path"
答案 1 :(得分:2)
您也可以通过将“Visual Studio命令提示符”作为“以管理员身份运行”选项启动来解决此类问题。现在使用installutil.exe命令安装程序集
x:\Windows\System32>installutil.exe YourService.exe
(其中YourService.exe是服务项目的已编译exe文件)
路线:强> 要打开命令提示符,请单击“所有程序” - > “Microsoft Visual Studio(20xx)” - > “Visual Studio Tools(20xx)” - > “Visual Studio命令提示符”(其中20xx是您使用的相应版本,如2008年,2010年等)。