System.BadImageFormatException: How to fix .NET ve

2020-06-14 07:50发布

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.)

3条回答
看我几分像从前
2楼-- · 2020-06-14 08:17

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.

查看更多
神经病院院长
3楼-- · 2020-06-14 08:27

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.

查看更多
可以哭但决不认输i
4楼-- · 2020-06-14 08:33

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.

查看更多
登录 后发表回答