【QC开发相关】解决无法创建TDConnection(OTAClient.dll中提供)对象的问题(错误0x800703e6)

来源:互联网 发布:淘宝劵 编辑:程序博客网 时间:2024/05/01 23:18
在使用VS2008、VS2010开发C#程序时,使用OTAClient.dll做一些QC相关操作,会遇到创建TDConnection失败的情况,错误码是0x800703e6。具体错误信息为:
System.BadImageFormatException: Retrieving the COM class factory for component with CLSID{C5CBD7B2-490C-45F5-8C40-B8C3D108E6D7} failed due to the following error: 800703e6.

解决办法是在工程的Post Build Event里加入下面两行:
call "$(DevEnvDir)..\tools\vsvars32.bat"
editbin.exe /NXCOMPAT:NO $(TargetPath)


产生这个错误的原因是C#编译器会为程序默认开启数据执行保护(Data Execution Prevention),这造成加载OTAClient.dll失败,我们需要通过editbin.exe关闭这个特性。

相关问题解决方案:
http://www.sqaforums.com/showflat.php?Number=449845&page=0
http://blogs.msdn.com/b/ed_maurer/archive/2007/12/14/nxcompat-and-the-c-compiler.aspx

数据执行保护机制介绍:
http://technet.microsoft.com/zh-cn/library/cc738483(v=ws.10).aspx