简体   繁体   中英

BadImageFormatException - Merging C# Console project with C# Windows Form project

I have a Console app that I am able to compile and run without issue using C# and.Net Core. This code takes advantage of a DLL that's used to execute some API calls to another application. I've been tasked with creating Windows Form application that does the same operations, but when i use the same code and add it to my windows form project, I get an exception when I try to load it: BadImageFormatException

I have no idea how to work around this or why it's coming up. I've tried changing the CPU setting, but nothing works. It's worth noting that the settings between the console and windows projects are the same regarding the CPU type. One thing that is different is that when I compile the console App, a DLL is formed by the project. This DLL is not created when I compile the Windows project.

Found that the issue was that the library was x64 and for teh console app, it doesn't matter how I compile it, but for the windows app, I had to set it to x64. I believed it to be a 32-bit since it was an old app, which is why I tried x86.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM