System.BadImageFormatException: How to fix .NET version mismatch?

旧街凉风 提交于 2019-12-12 07:49:32

问题


I wrote a dll in VS 2005 that will be loaded by another program that was developed in VS 2003. When that program tries to load my dll, it throws a System.BadImageFormatException: The format of the file 'Foo.dll' is invalid.

I searched SO and Google, and it seems that the different version of .NET is the culprit. My question is: How do I fix this?

(I cannot modify the program developed in VS 2003.)


回答1:


Compile the VS2005 Project with the same .Net Version as your VS2003 Project uses. Or, depending of the size of your VS2003 Project, reflector and rewrite it. That's common practice for projects over here, where for some obscure reason there is no more VSS version available.




回答2:


I got this error when I was running the 64bit version of the CLR and trying to load an assembly that was marked 32bit only. The specific assembly in my case was the Oracle.DataAccess.dll that comes as part of ODP.NET.




回答3:


SOLUTION: If you are on IIS7, Right Click/ Advanced Settings on the Specific Application Pool of the website and select True on Enable 32-Bit Applications. It should work.



来源:https://stackoverflow.com/questions/826038/system-badimageformatexception-how-to-fix-net-version-mismatch

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