BadImageFormatException when creating installer with VisualStudio 2019

0

hope you are doing great.

I am trying to create an installer for my project (a modified MissionPlanner, for those who know that open source software) with VisualStudio 2019. I am doing it with the setup project of Visual Studio. I managed to create an installer, and install the software on my computer. However, when I try to use my application, I have the error

INFO MissionPlanner.Program - ******************* Logging Configured

INFO MissionPlanner.Program - C:\Program Files (x86)\Default Company
Name\Setup1\x64\libSkiaSharp

INFO MissionPlanner.Program - 64bit os True, 64bit process True, OS
Arch X64

INFO MissionPlanner.Program - Runtime Version v4.0.30319

FATAL MissionPlanner.Program - Fatal app exception

System.TypeInitializationException: Une exception a été levée par
l'initialiseur de type pour 'MissionPlanner.MainV2'. --->
System.BadImageFormatException: Impossible de charger le fichier ou
l'assembly 'System.ValueTuple, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=cc7b13ffcd2ddd51' ou une de ses dépendances. Les
assemblys de référence ne doivent pas être chargés pour l'exécution.
Ils ne peuvent être chargés que dans le contexte de chargeur de
réflexion uniquement. (Exception de HRESULT : 0x80131058) --->
System.BadImageFormatException: Impossible de charger un assembly de
référence pour l'exécution.

I've read across the internet and all the similar topics that this is problem between 32 bits and 64 bits. However, I think I have tried pretty much everything, but it still does not work. What I tried :

    • Compile in "Any CPU" mode in the configuration manager
    • Right click on the project and "Properties" then "Target Platform" to Any CPU
    • Right click on the project and "Properties" then Uncheck "Prefer 32 bits"
    • Compile in "Any CPU" mode in the configuration manager
    • Right click on the project and "Properties" then "Target Platform" to Any CPU
    • Right click on the project and "Properties" then Check "Prefer 32 bits"
    • Compile in "x64" mode in the configuration manager
    • Right click on the project and "Properties" then "Target Platform" to x64
    • Right click on the project and "Properties" then Uncheck "Prefer 32 bits"
    • Click on the Setup project properties window then target "x64"
    • Compile in "x86" mode in the configuration manager
    • Right click on the project and "Properties" then "Target Platform" to x86
    • Right click on the project and "Properties" then Uncheck "Prefer 32 bits"
    • Click on the setup project then properties window then target "x86"
    • Compile in "x86" mode in the configuration manager
    • Right click on the project and "Properties" then "Target Platform" to x86
    • Right click on the project and "Properties" then Check "Prefer 32 bits"
    • Click on the setup project then properties window then target "x86"

I really don't know what I'm doing wrong, and what I should do in order for this to work, I really need your help !

Thank you

visual-studio
badimageformatexception
asked on Stack Overflow May 20, 2021 by nicolas

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0