System.BadImageFormatException when installing service

后端 未结 3 516
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 14:14

I am getting below exception when I try to run installer to set up service:

# ./InstallUtil ../../../../Applications/GasPosApp/bin/Wrapper.exe -s ../../../
.         


        
3条回答
  •  猫巷女王i
    2020-12-29 14:55

    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

    • Check your opearting system format? x86 or x64
    • Check your project build configuration?
    • Check all refreanced assebmlies (VERY IMPORTENET) if one of your loaded refreances (DLL's) is built in the wrong format you will get this error also (Correct me if I'm wrong!).
    • If possible change your VS buid configurartion to AnyCpu.

    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 
    

提交回复
热议问题