【问题标题】:Exe installation throwing error The module was expected to contain an assembly manifest .Net CoreExe安装抛出错误该模块应包含程序集清单.Net Core
【发布时间】:2020-06-04 10:54:42
【问题描述】:

我已经使用.Net Core worker service 实现了windows service。从命令提示符安装服务时出现错误

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe D:\LC\WindowService\L3WorkerService.exe
Microsoft (R) .NET Framework Installation utility Version 4.8.3752.0
Copyright (C) Microsoft Corporation.  All rights reserved.

Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 
'file:///D:\LC\WindowService\L3WorkerService.exe' or one of its dependencies. 
The module was expected to contain an assembly manifest..

这两条路我都试过了

C:\Windows\Microsoft.NET\Framework64\v4.0.30319>InstallUtil.exe D:\LC\WindowService\L3WorkerService.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319>InstallUtil.exe D:\LC\WindowService\L3WorkerService.exe

这是我的项目信息

  • 平台目标 - x86
  • 输出类型 - WindowsApplication
  • 目标框架 - .NET Core 3.1

我该如何解决这个问题?

【问题讨论】:

  • 为什么要使用 .NET FW 中的 InstallUtil.exe 来安装 .NET Core 服务?
  • @PavelAnikhouski - 我是 .Net 的新手,只是按照文章安装服务。我该怎么做?谢谢。
  • 你可以google一下找到一些msdn文章,比如Host ASP.NET Core in a Windows Service并关注他们

标签: c# .net .net-core windows-services


【解决方案1】:

要安装服务需要遵循以下步骤

以管理员身份打开cmd 并切换到项目的输出/发布目录。然后输入

sc create TestService BinPath=D:\LC\WindowService/TestService.exe

您将收到消息[SC] CreateService SUCCESS。其他命令也可用,包括start service

sc start TestService
sc stop TestService
sc delete TestService

注意:在 .Net Core 服务中避免使用InstallUtil.exe

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多