BadImageFormatException错误使用InstallUtil工具 [英] BadImageFormatException error in using InstallUtil tool

查看:311
本文介绍了BadImageFormatException错误使用InstallUtil工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已创建和编译使用.NET 4.0
所以我去.NET 4.0文件夹,并说这句话我的Windows服务:
我复制bin文件夹到C盘,以更短的路径:

I have created and compiled my windows service using .NET 4.0 So I go to .NET 4.0 folder and say something like this: I copied the bin folder to C drive to make path shorter:

InstallUtil.exeC:\bin\Debug\MyTestService.exe

InstallUtil.exe "C:\bin\Debug\MyTestService.exe"

这是我得到的错误:

在初始化安装时出现异常:
System.BadImageFormatException:无法加载文件或程序
'的file:/// C:\bin Debug\MyTestService.exe或它的一个依赖。
试图加载格式不正确的程序。

Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'file:///C:\bin Debug\MyTestService.exe' or one of its dependencies. An attempt was made to load a program with an incorrect format..

所以我不知道该怎么办。

So I don't know what to do.

推荐答案

当您使用installutil的错误版本的错误发生。举例来说,你正在使用installutil.exe用于.NET 2.0,但你的目标的exe是建立与4.0或您正在使用64位的DLL / EXE installutil的32位版本。

That error happens when you use the wrong version of installutil. For instance, you are using installutil.exe for .NET 2.0 but your target exe is built with 4.0 or you are using a 32 bit version of installutil on a 64 bit dll/exe.

这篇关于BadImageFormatException错误使用InstallUtil工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆