【发布时间】:2011-05-12 02:58:18
【问题描述】:
所以我用 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 中构建设置,则必须将 .net 4 部署到服务器
-
但是我可以在 Visual Studio 中构建项目本身。这不应该意味着.NET 4.0 已经安装了吗?
-
刚刚尝试安装它 - 它已经安装了。
-
不是 32/64 位问题吧?
-
我已经尝试过 installutil 的 32 位和 64 位版本;两者都不起作用。
标签: c# .net windows-services failed-installation