所以我在 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。
有人遇到过这个问题吗?
最佳答案
如果您的应用程序是针对 .Net 4.0 构建的,您使用的是错误的 installutil.exe。使用4.0文件夹下的installutil.exe。
对于 x86:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe
对于 x64:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil.exe
关于c# - 为什么我不能安装我的服务(运行时比加载的运行时更新)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4216606/