【问题标题】:Why can't InstallUtil.exe find the manifest file?为什么 InstallUtil.exe 找不到清单文件?
【发布时间】:2023-03-28 22:33:01
【问题描述】:

我正在尝试按照本教程创建 Windows 服务:

https://www.c-sharpcorner.com/UploadFile/8a67c0/create-and-install-windows-service-step-by-step-in-C-Sharp/

我正在使用批处理代码安装服务:

@echo off
cd C:\Users\User\Desktop\C#\TestService\bin\Debug
set DOTNET=%SystemRoot%\Microsoft.NET\Framework\v2.0.50727
set PATH=%PATH%;%DOTNET%
installutil.exe /i TestService.exe
net start TestService
pause
net stop TestService
installutil.exe /u TestService.exe

当我运行这个文件时,我得到以下错误:

初始化安装时发生异常: System.BadImageFormatException:无法加载文件或程序集 'file:///C:\Users\User\Desktop\C#\TestService\bin\Debug\TestService.exe' 或其依赖项之一。该模块应包含一个程序集清单。 服务名称无效。

它说该模块应该包含一个清单,但目录中有一个清单文件。 我已经尝试重建,但它没有改变。

任何帮助将不胜感激。

【问题讨论】:

    标签: c# .net windows-services installutil


    【解决方案1】:

    我将 DOTNET 路径更改为 %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319 并确保每次都以管理员身份运行。这似乎可以解决问题。

    【讨论】:

      猜你喜欢
      • 2011-12-14
      • 2010-10-12
      • 1970-01-01
      • 1970-01-01
      • 2022-11-29
      • 1970-01-01
      • 2021-10-06
      • 2023-03-31
      • 2021-12-09
      相关资源
      最近更新 更多