[Insight-users] ManagedITK: cannot load assembly (System.BadImageFormatException)

Dan Mueller dan.muel at gmail.com
Thu May 27 00:54:29 EDT 2010


Hi Charles,

MSDN documentation has the following statement:
    In particular, the exception is thrown under the following conditions:
    * A DLL or executable is loaded as a 64-bit assembly, but it contains
    32-bit features or resources. For example, it relies on COM interop
    or calls methods in a 32-bit dynamic link library.

I suspect this is the culprit (seeing you list your machine as Windows
7 64-bit).

Some questions:

1. Are you using the x86 pre-compiled binaries?
   FYI there are some older x64 binaries here:
   http://manageditk.googlecode.com/files/ManagedITK-bin-x64-3.10.0.1.zip
   (I no longer have access to a 64-bit machine, so can't pre-build
these binaries anymore.)

2. Is the .NET program you are calling ManagedITK from the same build
type as the binaries (ie. if using x86 ManagedITK binaries, your
program should be x86, or vice-versa).

3. Perhaps you could post a minimal example (ManagedITK.Common.dll, C#
console program, VS solution/project file)?

Cheers, Dan

2010/5/25 Charles Brossollet <chbrossotaf at gmail.com>:
> Hello,
>
> I'm trying the examples of ManagedITK with the prebuilt assembly, and while building works, execution of examples lead to this exception (complete text below, sorry it's in French).
>
> I ran PeVerify on ManagedITK.Common, and got this:
>  [MD]: Unverifiable PE Header/native stub.
> 1 Error Verifying C:\charles\ManagedITK-bin-x86-3.14.0.0\Exemples\Buildx86\bin\debug\ManagedITK.Common.dll
>
> I use VC 2008, on Windows 7 Professional 64 bits.
>
> What can happen?
>
> Thanks for help,
> Charles
>
> Exception non gérée : System.BadImageFormatException: Impossible de charger le fichier ou l'assembly 'ManagedITK.Common, Version=3.14.0.0, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances. Tentative de chargement d'un programme de format incorrect.
> Nom du fichier : 'ManagedITK.Common, Version=3.14.0.0, Culture=neutral, PublicKeyToken=null'
>   à itk.Examples.Filters.RescaleIntensity1.Main(String[] args)
>
> Gestionnaire des assemblys chargé à partir de :  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
> Exécution sous l'exécutable  C:\charles\ManagedITK-bin-x86-3.14.0.0\Exemples\Examples\bin\Debug\itk.Examples.Filters.RescaleIntensity1.exe
> --- Un journal des erreurs détaillé suit.
>
> === Informations d'état de liaison préalable ===
> JRN : utilisateur = CHARLESBROS223F\Administrateur
> JRN : DisplayName = ManagedITK.Common, Version=3.14.0.0, Culture=neutral, PublicKeyToken=null
>  (Fully-specified)
> JRN : Appbase = file:///C:/charles/ManagedITK-bin-x86-3.14.0.0/Exemples/Examples/bin/Debug/
> JRN : PrivatePath initial = NULL
> Assembly appelant : itk.Examples.Filters.RescaleIntensity1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
> ===
> JRN : cette liaison démarre dans le contexte de chargement de default.
> JRN : aucun fichier de configuration de l'application n'a été trouvé.
> JRN : utilisation du fichier de configuration de l'ordinateur à partir de C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
> JRN : stratégie non appliquée à la référence à ce stade (liaison d'assembly privée, personnalisée, partielle ou basée sur l'emplacement).
> JRN : tentative de téléchargement de la nouvelle URL file:///C:/charles/ManagedITK-bin-x86-3.14.0.0/Exemples/Examples/bin/Debug/ManagedITK.Common.DLL.
> ERR : impossible de terminer l'installation de l'assembly (hr = 0x8007000b). Détection terminée.


More information about the Insight-users mailing list