ClickOnce: BadImageFormatException when running x86 package on 64 bit windows

跟風遠走 提交于 2019-12-05 11:25:11

This was resolved by installing VS 2008 SP1 on 64 bit Windows 7. VS2008 SP1 on XP had the problem on two machines I have tried with.

I had this problem as well, using VS2008 SP1. In my case I had a 32 bit DLL which had to be compiled as 32 bit and an application that was using it in the same solution. Even though I specified X86 as the build target for the release build, when I published a 64bit application was compiled and included in the installer. I found a slightly brutal solution to the problem: Go into the configuration manager and remove all possible configurations except the one that you want it to build (Debug and release versions). After doing this I found that the clickonce installer was generated with the correct application.

I hope this helps someone else, I have been battling this problem on and off for months.

I'd suggest to use Reflector to open the main exe deployed by ClickOnce and see the dependencies to make sure you are not deploying the 64 bit version of the dll by mistake.

You must resolve to run 32-Bit Applications in IIS 7. See http://www.fishofprey.com/2009/04/badimageformatexception-in-iis-70-on-64.html

Sometimes the ClickOnce publishing process seems to cache old files from previous Any CPU or x64 builds. Doing a Clean and Rebuild All didn't fix this problem for me. I needed to delete all of the bin and obj folders from my projects and reopen Visual Studio.

We ran into this problem and determined that the subdirectory of the user profile to which ClickOnce deployed our application must have become corrupted, because we were able to deploy the application successfully with ClickOnce when logged in as a different user on the same machine.

We were able to solve the problem simply by deleting the subdirectory of C:\Users\<user>\AppData\Local\Apps under which ClickOnce was deploying our application. In our case, this was C:\Users\<user>\AppData\Local\Apps\2.0.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!