Service is being created with executable path pointing to DLL instead of EXE
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- csharp
调研方向
从 ManagedInstallerClass.InstallHelper 和 issue 中所示的 ServiceInstaller 设置开始,然后使用 Assembly.GetExecutingAssembly().Location 和 Environment.ProcessPath 重现 .NET 6 安装过程。跟踪库如何推导服务二进制文件路径,并通过成功安装服务来验证修复,同时将服务配置为启动预期的可执行文件。
由索引模型根据 Issue 内容生成。
描述
We have a service installation code which works just fine with .NET Frameworks 4.8 Console application based on ServiceBase:
ManagedInstallerClass.InstallHelper(new string[] { Assembly.GetExecutingAssembly().Location });
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
namespace TestServiceInstall
{
[RunInstaller(true)]
public class TestServiceInstaller : Installer
{
public TestServiceInstaller()
{
ServiceProcessInstaller processInstaller = new ServiceProcessInstaller();
ServiceInstaller serviceInstaller = new ServiceInstaller();
// set the privileges
processInstaller.Account = ServiceAccount.LocalSystem;
serviceInstaller.DisplayName = GlobalVar.SERVICE_NAME;
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.DelayedAutoStart = true;
serviceInstaller.ServicesDependedOn = new string[] { "Tcpip" };
// must be the same as what was set in Program's constructor
serviceInstaller.ServiceName = GlobalVar.SERVICE_NAME;
// installer code here
this.AfterInstall += new InstallEventHandler(ServiceInstaller_AfterInstall);
this.Installers.Add(processInstaller);
this.Installers.Add(serviceInstaller);
}
void ServiceInstaller_AfterInstall(object sender, InstallEventArgs e)
{
ServiceController sc = new ServiceController(GlobalVar.SERVICE_NAME);
sc.Start();
}
}
}
We tried to migrate to .NET 6.0 and use this library to install the service in a same way we used to, but what happens is service binary path changed from EXE file to DLL file and we can't figure out how to point it to the EXE file.
We've tried changing Assembly.GetExecutingAssembly().Location to Environment.ProcessPath but it gives us the following error:
System.BadImageFormatException: Bad IL format. The format of the file '%EXE path here%' is invalid..
So the question is how can we use this library to install a windows service pointing to EXE file instead of DLL?
- 主要语言
- C#
- 星标
- 26
- 派生
- 12
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
flamencist/Core.System.Configuration.Install 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 30/100
flamencist/Core.System.Configuration.Install#11 · 2 个 reaction ·
-
难度 4/5 3-5 天 新手友好度 20/100
flamencist/Core.System.Configuration.Install#9 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
flamencist/Core.System.Configuration.Install#1 · 3 条评论 · 1 个 reaction ·
查看 flamencist/Core.System.Configuration.Install 的全部 Issue
相似的 Issue
-
needs triage
难度 2/5 1-3 小时 新手友好度 68/100
spectreconsole/spectre.console#2221 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 92/100
-
area/navigationview 🧭 difficulty/starter 🚀 good first issue kind/bug platform/all project/navigation-lifecycle 🧬 triage/untriaged
难度 2/5 1-3 小时 新手友好度 76/100
unoplatform/uno#24925 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
PhilippC/keepass2android#3315 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
DamianEdwards/ghcp-spend-tray#39 ·
维护者通常 1 天内回复