随笔-108  评论-111  文章-2  trackbacks-0

ASP.NET: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. on Win7 64bit

These message as blow:

Server Error in '/WebService' Application.
--------------------------------------------------------------------------------

Could not load file or assembly '******' or one of its dependencies. An attempt was made to load a program with an

incorrect format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace

for more information about the error and where it originated in the code.

Exception Details: System.BadImageFormatException: Could not load file or assembly 'DHI.DHIfl' or one of its dependencies.

An attempt was made to load a program with an incorrect format.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and

location of the exception can be identified using the exception stack trace below. 

Assembly Load Trace: The following information can be helpful to determine why the assembly 'DHI.DHIfl' could not be loaded.


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

以上参考:http://www.lazyasscoder.com/Article.aspx?id=90&title=System.BadImageFormatException%3A+An+attempt+was+made+to+load+a+program+with+an+incorrect+format.++on+Win2k8+64bit%2C+IIS7%2C+Oracle

 

My .NET web service used to live in a 32-bit Windows 2003 server running under IIS6 connecting to an Oracle database.  I had to migrate my web service to a new 64-bit Windows 2008 server running IIS7.  This is when the following error started:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
  at Oracle.DataAccess.Client.OpsTrace.GetRegTraceInfo(UInt32& TrcLevel)
  at Oracle.DataAccess.Client.OraTrace.GetRegistryTraceInfo()
  at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)



What the hell does this error means, no body knows.  After alot of googling and playing around on the server with IIS, I finally figured out the solution to my problem.
Because my web service application was using an older 32-bit Oracle driver, I had to force IIS7 to run in 32-bit mode and this is how I did it.
Under IIS7, my web application was running in an application pool.
  1. Right clicked over the AppPool name 
  2. Selected Advanced Settings...
  3. Under the General Section, set Enable 32-Bits Application to True
  4. Click OK, you may want to recycle the application pool just to be sure.
Done, nice and simple. No code changes required.


 

贴图:

作者:LiFuyun
出处:http://lifuyun.cnblogs.com
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
posted on 2011-09-23 17:51 云中深海 阅读(615) 评论(2) 编辑 收藏

评论:
#1楼[楼主] 2011-09-28 13:13 | 云中深海      
额~~~第一次用64位的win7来开发,出现如此的问题,中文网站还没有解决办法,不过在外文的网站上看参考的细节解决了,高兴啊!不过,另外一个问题出现了,silverlight不能在跨网段里运行吗?测试了,cs的socket通信是可以的
 回复 引用 查看   
#2楼[楼主] 2011-09-28 16:50 | 云中深海      
从 Silverlight 应用程序对网络资源的跨域访问也可能会受到域、本地 Intranet 和本地计算机上已设定的其他安全性和防火墙策略的限制。例如,其他安全性和防火墙策略可能会限制对 http://contoso 形式的 URI 的访问,而允许对具有全限定域名的 http://www.contoso.com 的类似 URI 的访问。

对于使用 System.Net.Sockets 的网络连接,Silverlight 中的安全策略系统将同时影响源站点和跨域网络访问。使用套接字的所有连接都需要安全策略,即使当连接回到源站点时也是如此。

Silverlight 中的安全策略系统可以防止启动未经授权的连接,以及防止针对本地计算机或本地网络上的其他设备的可能网络攻击威胁;但同时,这些策略检查也为部署合法 Silverlight 应用程序设置了屏障。为了方便编写和部署使用 System.Net.Sockets 进行通信的 Silverlight 应用程序,Silverlight 版本 4 为浏览器外受信任的应用程序引入了较为宽松的限制。使用此功能,经过用户授权的浏览器外 Silverlight 应用程序运行在扩展的沙盒中,而不必接受对 System.Net.Sockets 的安全策略检查。有关浏览器外支持和受信任的应用程序的一般信息,请参见浏览器外支持主题和受信任的应用程序主题。

 回复 引用 查看   
LiFuyun.Net

本Blog上的任何言论仅代表个人观点或收藏精彩文章等,与作者所在的公司或个人没有任何关系。
本Blog的内容按原样提供,作者不提供任何形式的担保。
欢迎大家一起探讨,共同进步!

 

个人CSDN-BLOG
深海软件信息技术服务网
飘逸软件技术信息服务网
技术方向:
    C#  Asp.NET ArcGIS JavaScript SilverLight PHP Java等
数据库:
    SQL Server Oracle MySQL
目前居住于:
    中国上海

联系方式:
LiFuyun.Net-CloudyDeepSea


点击这里通过MSN给我发消息

点击这里通过QQ给我发消息

参与项目:
    上海市各区县防汛网、WebGIS系统开发、上海市排水管理处行业信息管理系统、青浦水情地理信息系统、上海市污水处理厂在线环保监测系统等等。


昵称:云中深海
园龄:2年11个月
粉丝:36
关注:20
<2011年9月>
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678

搜索

 

常用链接

我的标签

随笔分类

随笔档案

文章分类

文章档案

相册

博客友人

网店链接

最新评论

阅读排行榜

评论排行榜

推荐排行榜