因此,我在 C# 中构建了一个服务,并尝试使用以下命令来安装它:
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\installutil.exe MyService.exe >> installLog.txt
它失败。当我查看 installLog.txt 时,我得到了这个:
Microsoft (R) .NET Framework Installation utility Version 2.0.50727.3053
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\MyService.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..
同样的方法适用于安装不同的组件。我觉得可能是因为失败的是为 .NET 4.0 编写的,而有效的是 3.5 中的。
有没有人有这个问题的经验?