Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BadImageFormatException error in using InstallUtil tool

Tags:

c#

installutil

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.exe "C:\bin\Debug\MyTestService.exe"

and this is the error I get:

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.

like image 272
Bohn Avatar asked Jun 15 '12 23:06

Bohn


1 Answers

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.

like image 116
Russell McClure Avatar answered Oct 25 '22 17:10

Russell McClure