14

I use VS 2012 and since the setup projects have been removed from it I have to use InstallUtil.exe.

I don't have projectInstaller class in my windows service app. 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. 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. The file is located at 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'. 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.

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. The file is located at 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'. 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. Remove InstallState file because there are no installers.

The Commit phase completed successfully.

The transacted install has completed.

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)

Installation of FilesMonitoringService... Creation of EventLog FilesMonitoringService in a log jornal Application...

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. Not available jornals: Security.

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.
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? I also set this properies in a properties window:

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

Or can it be implemented without projectInstaller?

4

3 回答 3

19

好的,有几件事:

1)您需要项目安装程序。
2)你的项目->属性;启动项目 -> YourProject.Program
3)构建
4)“以管理员身份运行”命令提示符!

现在一切正常。

完整教程链接

于 2013-02-22T07:59:20.987 回答
1

我现在没有VS2012的副本来测试它,但我相信你的问题与

我的 Windows 服务应用程序中没有 projectInstaller 类

部分。

来自msdn

安装组件在要安装它的系统上注册单个服务,并让服务控制管理器知道该服务存在

于 2013-02-21T18:14:33.727 回答
0

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

于 2015-05-23T06:07:33.010 回答