标签: installutil

安装不带InstallUtil.exe的.NET Windows服务

我有一个用C#编写的标准.NET Windows服务.

它可以在不使用InstallUtil的情况下自行安装吗?我应该使用服务安装程序类吗?我该怎么用?

我希望能够拨打以下电话:

MyService.exe -install
Run Code Online (Sandbox Code Playgroud)

它将具有与调用相同的效果:

InstallUtil MyService.exe
Run Code Online (Sandbox Code Playgroud)

.net c# deployment windows-services installutil

163
推荐指数
5
解决办法
15万
查看次数

安装在Visual Studio中创建的Windows服务

当我在Visual Studio 2010中创建新的Windows服务时,我收到消息,声明使用InstallUtil和net start来运行该服务.

我尝试了以下步骤:

  1. 创建新项目文件 - >新建 - >项目 - > Windows服务
  2. 项目名称:TestService
  3. 按原样构建项目(Service1构造函数,OnStart,OnStop)
  4. 打开命令提示符,运行"C:\ Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe"TestService.exe
  5. 运行net start TestService.

步骤4的输出

运行事务安装.

开始安装的安装阶段.

请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.

该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.

安装程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_dj\x86\Debug\TestService.exe'.

受影响的参数是:

logtoconsole =

logfile = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\T\testService\_dj\x86\Debug\TestService.InstallLog

assemblypath = C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestServ ice\TestService\obj\x86\Debug\TestService.exe

没有具有RunInstallerAttribute.Yes属性的公共安装程序可以在C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestSe rvice\_ obj\x86\Debug\TestService.exe程序集中找到.

安装阶段成功完成,提交阶段正在开始.

请参阅日志文件的内容以获取C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestService\TestService\obj\x86\Debug\TestService.exe程序集的进度.

该文件位于C:\ Users\myusername\Documents\Visual Studio 2010\Projects\Tes tService\TestService\_dj\x86\Debug\TestService.InstallLog.

提交程序集'C:\ Users\myusername\Documents\Visual Studio 2010\Projects\TestS ervice\TestService\_obj\x86\Debug\TestService.exe'.

受影响的参数是:

logtoconsole = …

c# windows service windows-services installutil

134
推荐指数
4
解决办法
14万
查看次数

在服务器上安装相同Windows服务的多个实例

所以我们已经制作了一个Windows服务来将数据提供给我们的客户端应用程序,一切都很顺利.客户端提出了一个有趣的配置请求,该请求要求在同一服务器上运行此服务的两个实例,并将其配置为指向不同的数据库.

到目前为止,我还没有能够实现这一点,并希望我的同事stackoverflow成员可以提供一些提示,为什么.

目前的设置:

我已经设置了包含windows服务的项目,从现在开始我们称之为AppService,以及处理自定义安装步骤的ProjectInstaller.cs文件,根据App.config中的键设置服务名称,如此:

this.serviceInstaller1.ServiceName = Util.ServiceName;
this.serviceInstaller1.DisplayName = Util.ServiceName;
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
Run Code Online (Sandbox Code Playgroud)

在这种情况下,Util只是一个静态类,可以从配置文件中加载服务名称.

从这里开始,我尝试了两种不同的方法来安装这两种服务,并且都以相同的方式失败.

第一种方法是简单地安装服务的第一个副本,复制已安装的目录并重命名,然后在修改应用程序配置后运行以下命令以更改所需的服务名称:

InstallUtil.exe /i AppService.exe
Run Code Online (Sandbox Code Playgroud)

当这不起作用时,我尝试创建第二个安装程序项目,编辑配置文件并构建第二个安装程序.当我运行安装程序时它工作正常,但服务没有显示在services.msc中,所以我针对第二个安装的代码库运行了上一个命令.

两次我都收到了InstallUtil的以下输出(仅限相关部分):

运行事务安装.

开始安装的安装阶段.

安装服务App Service Two ... Service App Service 2已成功安装.在日志应用程序中创建EventLog源App Service二...

安装阶段发生异常.System.NullReferenceException:未将对象引用设置为对象的实例.

安装的回滚阶段正在开始.

将事件日志还原到源App Service 2的先前状态.服务应用程序服务2正在从系统中删除...服务应用程序服务2已成功从系统中删除.

回滚阶段成功完成.

事务处理安装已完成.安装失败,并且已执行回滚.

对于冗长的帖子感到抱歉,想确保有足够的相关信息.到目前为止已经难倒我的部分是,它指出该服务的安装成功完成和它关系到创建的NullReferenceException异常似乎得到抛出的事件日志源之后.因此,如果有人知道我做错了什么或有更好的方法,那将非常感激.

windows windows-installer windows-services installutil

92
推荐指数
6
解决办法
9万
查看次数

无法安装Windows服务

我使用visual studio 2010和.N ET 4.0创建了一个非常简单的窗口服务.

除了添加了安装程序之外,此服务没有从默认的Windows服务项目添加任何功能.

如果我在我的开发箱或我们域中的其他Windows 2008 R2计算机上运行"installutil.exe appName.exe",则Windows服务安装没有问题.

当我尝试在我们的客户站点上执行相同的操作时,它无法安装,并出现以下错误.

Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\TestService\WindowsService1.exe' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515).
Run Code Online (Sandbox Code Playgroud)

此解决方案只有一个项目,并且没有添加依赖项.

我在我们环境中的多台机器上尝试过,在客户中尝试过两台.这些机器都是windows 2008 R2,都是全新安装.一台机器只有.net 2.0和.net 4.0.另一个.net 2,3,3.5和4.

我是每台机器上的本地管理员.

我也尝试了64位安装程序,但得到以下错误,所以我认为32位的是一个使用的. System.BadImageFormatException

任何指导将不胜感激.谢谢.

c# windows-services installutil .net-4.0

72
推荐指数
5
解决办法
5万
查看次数

用SC.exe或InstallUtil.exe安装Windows服务 - 有区别但是哪个?

SC.exeInstallUtil都安装/卸载Windows服务.但它们似乎没有同样的方式.

有什么不同?


例如,当Sc create愉快地安装服务时,InstallUtil失败(某些文件或依赖项未找到错误).太陌生了; 如果我在控制台中运行net start,则不会显示该服务.但它确实出现在服务GUI中.当我尝试卸载时会发生这种变化.

我自己写了这个服务,早期的版本工作.Dotnet3.5.

.net windows-services installutil

46
推荐指数
3
解决办法
3万
查看次数

使用InstallUtil安装.NET服务

我正在尝试安装我写的.NET服务.根据MSDN的建议,我使用的是InstallUtil.但我错过了如何在命令行甚至服务本身设置默认服务用户.现在,运行InstallUtil时,它会显示一个对话框,要求为用户凭证的用户.我正在尝试将服务安装集成到更大的安装中,并且需要服务安装保持静默.

.net windows-services installutil

37
推荐指数
1
解决办法
3万
查看次数

.net InstallUtil实用程序 - 32位对64位

我有一个编译为AnyCPU的Windows服务.我正试图将它放入我们的安装程序中进行分发.但是......我不清楚32位和64位版本的InstallUtil之间的区别.有谁知道有什么(如果有的话)?

在我的64位机器上,我可以运行$(WinDir)\ Microsoft.NET\Framework64\v2.0.50727或$(WinDir)\ Microsoft.NET\Framework\v2.0.50727.

在这两种情况下,任务管理器中生成的服务进程都没有应用*32标志.

只有32位的InstallUtil才能在32位机器上工作(显然).

是否需要使用\ Framework64 \版本的InstallUtil?它有什么不同的做法?

.net 64-bit installutil

16
推荐指数
1
解决办法
2万
查看次数

使用InstallUtil安装具有启动参数的Windows服务

我使用InstallUtil来安装我的服务,我只是无法弄清楚如何为它指定启动参数!

这是我的Installer子类:

[RunInstaller(true)]
public class ServerHostInstaller : Installer
{
  private ServiceInstaller m_serviceInstaller;
  private ServiceProcessInstaller m_serviceProcessInstaller;
  private static string s_usage = "Usage:\ninstallutil /i /username=<user_name> /password=<user_password> NCStub.Server.Host.exe";

  public ServerHostInstaller()
  {
    m_serviceInstaller = new ServiceInstaller();
    m_serviceInstaller.ServiceName = Program.ServiceName;
    m_serviceInstaller.DisplayName = Program.ServiceName;
    m_serviceInstaller.StartType = ServiceStartMode.Automatic;

    m_serviceProcessInstaller = new ServiceProcessInstaller();
    m_serviceProcessInstaller.Account = ServiceAccount.User;

    Installers.Add(m_serviceInstaller);
    Installers.Add(m_serviceProcessInstaller);
  }

  public override void Install(IDictionary stateSaver)
  {
    base.Install(stateSaver);

    string userName = this.Context.Parameters["username"];
    if (userName == null)
    {
      Console.WriteLine(s_usage);
      throw new InstallException("Missing parameter 'username'");
    }

    string userPass = this.Context.Parameters["password"];
    if (userPass …
Run Code Online (Sandbox Code Playgroud)

.net c# windows-services installutil

14
推荐指数
1
解决办法
2万
查看次数

C#Powershell snapin没有使用installutil进行注册

我有一个非常简单的PowerShell脚本(见下文).我在我的个人资料中使用以下内容获得了installutil别名:

set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
Run Code Online (Sandbox Code Playgroud)

在powershell中我简单地说:

installutil assemplylocation.dll
Run Code Online (Sandbox Code Playgroud)

这成功返回.(安装/提交都成功完成).然而,当我检查注册表时,或者在使用get-pssnapin -registered的powershell中,它没有显示我的程序集.我前几天做了这个,它工作正常,但我似乎无法复制它...请指教.

using System;
using System.Management.Automation;
using System.ComponentModel;

namespace PSBook_2_1
{
    [RunInstaller(true)]
    public class PSBookChapter2MySnapIn : PSSnapIn
    {
        public PSBookChapter2MySnapIn()
            : base()
        { }

    // Name for the PowerShell snap-in.
    public override string Name
    {
        get
        {
            return "Wiley.PSProfessional.Chapter2";
        }
    }

    // Vendor information for the PowerShell snap-in.
    public override string Vendor
    {
        get
        {
            return "Wiley";
        }
    }

    // Description of the PowerShell snap-in
    public override string Description
    {
        get
        {
            return …
Run Code Online (Sandbox Code Playgroud)

c# powershell installutil pssnapin

13
推荐指数
3
解决办法
8519
查看次数

正确的InstallUtil路径到文件语法?

我正在尝试使用批处理文件安装Windows服务,我们称之为"installservice.bat".在文件中我有以下命令:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe -i ".\MyService.exe"
    pause

当我执行批处理文件(在Vista上以管理员身份运行)时,我得到了这个:

Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Win
dows\system32\MyService.exe' or one of its dependencies. The system cannot f
ind the file specified..

实际服务位于C:\ Services\MyService.exe.".\ MyService.exe"部分应该使它正常运行?

syntax installutil path batch-file .net-2.0

11
推荐指数
2
解决办法
3万
查看次数