简体   繁体   English

无法在InstallUtil工具的帮助下安装Windows服务

[英]Unable to install windows service with the help of InstallUtil tool

I use VS 2012 and since the setup projects have been removed from it I have to use InstallUtil.exe. 我使用VS 2012,因为安装项目已从中删除,我必须使用InstallUtil.exe。

I don't have projectInstaller class in my windows service app. 我的Windows服务应用程序中没有projectInstaller类。 I run in command prompt: 我在命令提示符下运行:

installutil FilesMonitoringService.exe 

I get: 我明白了:

C:\\Program Files\\Microsoft Visual Studio 8\\VC#>installutil "C:\\Program Files\\Mic rosoft Visual Studio 8\\VC#\\CSharpProjects\\MyService\\MyService\\bin\\Release\\MyServ ice.exe" Microsoft (R) .NET Framework Installation utility Version 2.0.50727.42 Copyright (c) Microsoft Corporation. C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#> installutil“C:\\ Program Files \\ Mic rosoft Visual Studio 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin \\ Release \\ MyServ ice.exe”Microsoft(R) .NET Framework安装实用程序版本2.0.50727.42版权所有(c)Microsoft Corporation。 All rights reserved. 版权所有。

Running a transacted installation. 运行事务安装。

Beginning the Install phase of the installation. 开始安装的安装阶段。 See the contents of the log file for the C:\\Program Files\\Microsoft Visual Studi o 8\\VC#\\CSharpProjects\\MyService\\MyService\\bin\\Release\\MyService.exe assembly's progress. 请参阅日志文件的内容以获取C:\\ Program Files \\ Microsoft Visual Studi 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin \\ Release \\ MyService.exe程序集的进度。 The file is located at C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProj ects\\MyService\\MyService\\bin\\Release\\MyService.InstallLog. 该文件位于C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProj ects \\ MyService \\ MyService \\ bin \\ Release \\ MyService.InstallLog。 Installing assembly 'C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjec ts\\MyService\\MyService\\bin\\Release\\MyService.exe'. 安装程序集'C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProjec ts \\ MyService \\ MyService \\ bin \\ Release \\ MyService.exe'。 Affected parameters are: logtoconsole = assemblypath = C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjects\\ MyService\\MyService\\bin\\Release\\MyService.exe logfile = C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjects\\MySer vice\\MyService\\bin\\Release\\MyService.InstallLog No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjects\\MyService\\ MyService\\bin\\Release\\MyService.exe assembly. 受影响的参数是:logtoconsole = assemblypath = C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin \\ Release \\ MyService.exe logfile = C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC# \\ CSharpProjects \\ MySer vice \\ MyService \\ bin \\ Release \\ MyService.InstallLog没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin中找到\\ Release \\ MyService.exe程序集。

The Install phase completed successfully, and the Commit phase is beginning. 安装阶段成功完成,提交阶段正在开始。 See the contents of the log file for the C:\\Program Files\\Microsoft Visual Studi o 8\\VC#\\CSharpProjects\\MyService\\MyService\\bin\\Release\\MyService.exe assembly's progress. 请参阅日志文件的内容以获取C:\\ Program Files \\ Microsoft Visual Studi 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin \\ Release \\ MyService.exe程序集的进度。 The file is located at C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProj ects\\MyService\\MyService\\bin\\Release\\MyService.InstallLog. 该文件位于C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProj ects \\ MyService \\ MyService \\ bin \\ Release \\ MyService.InstallLog。 Committing assembly 'C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjec ts\\MyService\\MyService\\bin\\Release\\MyService.exe'. 提交程序集'C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProjec ts \\ MyService \\ MyService \\ bin \\ Release \\ MyService.exe'。 Affected parameters are: logtoconsole = assemblypath = C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjects\\ MyService\\MyService\\bin\\Release\\MyService.exe logfile = C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjects\\MySer vice\\MyService\\bin\\Release\\MyService.InstallLog No public installers with the RunInstallerAttribute.Yes attribute could be found in the C:\\Program Files\\Microsoft Visual Studio 8\\VC#\\CSharpProjects\\MyService\\ MyService\\bin\\Release\\MyService.exe assembly. 受影响的参数是:logtoconsole = assemblypath = C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin \\ Release \\ MyService.exe logfile = C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC# \\ CSharpProjects \\ MySer vice \\ MyService \\ bin \\ Release \\ MyService.InstallLog没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#\\ CSharpProjects \\ MyService \\ MyService \\ bin中找到\\ Release \\ MyService.exe程序集。 Remove InstallState file because there are no installers. 删除InstallState文件,因为没有安装程序。

The Commit phase completed successfully. 提交阶段成功完成。

The transacted install has completed. 事务处理安装已完成。

C:\\Program Files\\Microsoft Visual Studio 8\\VC#> C:\\ Program Files \\ Microsoft Visual Studio 8 \\ VC#>

OK , seems like everything have been installed. 好的 ,似乎已经安装了所有东西。 But! 但! When I go to task manager to the Services page I can't find my service. 当我到任务管理器到服务页面时,我找不到我的服务。

What could be the reason? 可能是什么原因?

Thanks in advance! 提前致谢!

Edits: I pointed out that I don't have projectInstaller class because if I add it (in designer -> add installer) and run installutil command I get: (approximate translation) 编辑:我指出我没有projectInstaller类,因为如果我添加它(在设计器 - >添加安装程序)并运行installutil命令我得到:(近似翻译)

Installation of FilesMonitoringService... Creation of EventLog FilesMonitoringService in a log jornal Application... FilesMonitoringService的安装...在log jornal应用程序中创建EventLog FilesMonitoringService ...

On this setup stage the exception occured. 在此设置阶段发生异常。

System.Security.SecurityException: The source is not found, but failed to find by any or all log jornals. System.Security.SecurityException:找不到源,但找不到任何或所有日志jornals。 Not available jornals: Security. 不可用的jornals:安全。

The recoil stage starts. 反冲阶段开始。

// lots of text //很多文字

The recoil stage has succeded 后坐阶段已经成功

Setup group operation executed. 安装组操作已执行。 Setup failed and recoil was executed. 安装失败并且执行了反冲。

So, if I add projectInstller to my windows service it definitely fails to install with installUtil. 因此,如果我将projectInstller添加到我的Windows服务,它肯定无法安装installUtil。
Here is the generated code: 这是生成的代码:

[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
    public ProjectInstaller()
    {
        InitializeComponent();
    }
    private void serviceInstaller1_AfterInstall(object sender, InstallEventArgs e)
    {}
    private void serviceProcessInstaller1_AfterInstall(object sender, InstallEventArgs e)
    {}
}

Mabby I need to put some code into afterInstall methods? Mabby我需要在AfterInstall方法中加入一些代码吗? I also set this properies in a properties window: 我还在properties窗口中设置了这个properties

serviceInstaller1: ServiceName -> FileMonitoringService, StartType -> Automatic serviceInstaller1:ServiceName - > FileMonitoringService,StartType - > Automatic
serviceProcessInstaller1: Account -> LocalSystem serviceProcessInstaller1:Account - > LocalSystem

Or can it be implemented without projectInstaller? 或者它可以在没有projectInstaller的情况下实现吗?

Ok, there are couple of things: 好的,有几件事:

1) You need projectInstaller. 1)您需要projectInstaller。
2) YourProject -> properties; 2)YourProject - > properties; Startup project -> YourProject.Program 启动项目 - > YourProject.Program
3) build 3)建立
4) “Run as Administrator” the command prompt! 4)“以管理员身份运行”命令提示符!

Everything works now. 现在一切都有效。

complete tutorial link 完整的教程链接

I don't have a copy of VS2012 to test it now, but I believe that your problem has something to do with the 我没有VS2012的副本来测试它,但我相信你的问题与它有关

I don't have projectInstaller class in my windows service app 我的Windows服务应用程序中没有projectInstaller类

part. 部分。

From msdn : 来自msdn

Installation components register an individual service on the system to which it is being installed and let the Services Control Manager know that the service exists 安装组件在要安装它的系统上注册单个服务,并让服务控制管理器知道该服务是否存在

这似乎微不足道,但在编写installutill参数时要仔细检查,因为您可能会将服务的exe文件与编译引用项目(没有服务安装程序)生成的另一个exe文件混淆,并使其失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM