Share via


Windows Azure VM Role: CSUPLOAD Exception System.BadImageFormatException: an attempt was made to load a program with an incorrect format

When you run CSUPLOAD tool on a Windows OS 7 32bit machine, you will receive the following error:

An unexpected error occurred: An attempt was made to load a program with an incorrect format (Exception from HRESULT: 0x8007000B)

Exception: System.BadImageFormatException: an attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

The detailed Exception looks as below:

 

C:\Azure>csupload Add-VMImage -Connection "SubscriptionId=xxxxx; CertificateThumbprint=xxxxxx; -Description "Base image Windows Server 2008 R2" -LiteralPath "c:\Azure\baseimage.vhd" -Name baseimage.vhd -Location "South Central US"

Windows(R) Azure(TM) Upload Tool 1.3.0.0

for Microsoft(R) .NET Framework 3.5

Copyright (c) Microsoft Corporation. All rights reserved.

Successfully passed the verification tests.

The mounted size of the VM image is 30 GB. This image can be used with the following Windows Azure VM sizes: Small, Medium, Large, ExtraLarge

Windows(R) Azure(TM) VHD Preparation Tool. 1.3.0.0

for Microsoft(R) .NET Framework 3.5

Copyright (c) Microsoft Corporation. All rights reserved.

Compressing VHD from c:\Azure\baseimage.vhd to c:\Azure\20110121133856Z4483690FF0694173BFE39998C4FF64B8.preped...

An unexpected error occurred: An attempt was made to load a program with an incorrect format (Exception from HRESULT: 0x8007000B)

Exception: System.BadImageFormatException: an attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

   Microsoft.WindowsAzure.Tools.CsVhdPrep.NativeMethods.BCCompressFile(String InputFilename, String OutputFilename, UInt32 Flags, PFN_RDBCAPI_PROGRESS Callback)

   Microsoft.WindowsAzure.Tools.CsVhdPrep.BlockCompress.CompressFile(String inputFile, String outputFile)

   Microsoft.WindowsAzure.Tools.CsVhdPrep.DoActions.Prepare(FileInfo inputVhd, FileInfo outputFile, FileInfo outputFileDigest)

   Microsoft.WindowsAzure.Tools.CsVhdPrep.ProgramCommands.PrepareVhdAction(IList`1 unnamedArgs, IDictionary`2 switches)

   Microsoft.WindowsAzure.Internal.Common.CommandParser.ParseCommand(CommandDefinition cmdDef, IEnumerable`1 commandArgs)

   Microsoft.WindowsAzure.Internal.Common.CommandParser.ParseCommand(IEnumerable`1 commandLine)

   Microsoft.WindowsAzure.Tools.CsVhdPrep.Program.ExecuteActions(String[] args)

   Microsoft.WindowsAzure.Tools.CsVhdPrep.Program.Main(String[] args)

Cannot prepare VHD c:\Azure\baseimage.vhd.

 

What actually happens is that CSUPLOAD calls csvhdprep which returns the following exception:

"An unexpected error occurred: an attempt was made to load a program with an incorrect format. Cannot prepare VHD {0}".

So the actual problem is caused by CSVHDPREP.EXE.

Solution:

To solve this problem you should run Windows Azure SDK 1.3 on a 64bit Windows 7 or Windows Server 2008 R2 machine to successfully use CSUPLOAD tool along with VM Role BETA.

During Windows Azure VM Role BETA phase CSUPLOAD tools is supported only on 64bit Windows OS however things may change later with respect to 32bit Support included with VM Role Tools.

Comments

  • Anonymous
    February 10, 2011
    Hi Avkash, I am following through your articles on this blogs and they are very informative. Thank you for that. I am trying to upload a vhd from my Windows 7 32 bit machine and it gives error "Can not find VM Role Agent. Failed the verification tests. cannot prepare VHD <vhd filepath>". Do you think the reason could be 32 bit machine again? Can you suggest how to resolve this error?

  • Anonymous
    March 09, 2011
    Amita i think your error is related to my question. Can a 32 bit OS be uploaded as a VM role?

  • Anonymous
    May 11, 2011
    Thank you guys!!Sorry I could not post my comments earlier. CSUPLOAD Tool is only supported with 64Bit OS.