使用IIS Express在调试ASP.NET网站的时候抛出异常 Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies. An attempt was made to load a program with an incorrect format.
看到incorrect format异常,大概是x64与x86的不兼容问题。然后去Bin目录检测一下每个dll的格式。发现无论是网站代码的dll是Any CPU格式, Oracle.DataAccess.dll是x64格式。按理说是没有问题的。然后在任务管理器中检查了一下iisexpress.exe进程,也是64位的,一切正常。
问题出在什么地方?最终找到了Visual Studio的设置。在Web Projects设置中,需要把Use the 64 bit version of IIS Express选中。这样它才是完全以64位的方式运行。