I am getting below exception when I try to run installer to set up service:
# ./InstallUtil ../../../../Applications/GasPosApp/bin/Wrapper.exe -s ../../../
../Applications/GasPosApp/properties/DispenserViewerApplication.wrapper.conf
Microsoft (R) .NET Framework Installation utility Version 4.0.30319.1
Copyright (c) Microsoft Corporation. All rights reserved.
Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Appl
ications\GasPosApp\bin\Wrapper.exe' or one of its dependencies. The module was e
xpected to contain an assembly manifest..
You have to use the right version of the InstallUtil. If you are trying install a 32 bit service (x86), use
c:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe
and if you are installing a 64 bit service (x64), use
c:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe
Note, that the last specified folder (v4.0.30319) may differ a machine from machine. If you have only an older version of the framework available you can encounter one of the following folders instead - v1.0.xxxx, v1.1.xxxx, v2.0.xxxxx, v3.0, v3.5.
This is often an indication of a mismatch between 32 and 64 bit. For instance if Wrapper.exe
is compiled as x86 and you install it using the 64 bit InstallUtil
the process cannot load the 32 bit Wrapper.exe
assembly and will throw a BadImageFormatException
.
The solution is to use the 32 bit InstallUtil
placed in the Framework
(not Framework64
) subfolder of the .NET folder (e.g. C:\Windows\Microsoft.NET\v4.0.30319\Framework
if you are using .NET 4 or 4.5).
I agree with all here! This error come, if you are trying to load your application or a one of the refreanced assemblies in an invalid operating system format.
http://msdn.microsoft.com/en-us/library/system.badimageformatexception(v=vs.80).aspx
Microsoft has created useful tool called CorFlags which can be used to show or set the targeted platform of an managed assembly.
C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\CorFlags.exe
Syntax:
CorFlags filename
**anycpu**
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0
**x86**
Version : v4.0.30319
CLR Header: 2.5
PE : PE32
CorFlags : 3
ILONLY : 1
32BIT : 1
Signed : 0
**x64**
Version : v4.0.30319
CLR Header: 2.5
PE : PE32+
CorFlags : 1
ILONLY : 1
32BIT : 0
Signed : 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With