我在我的 C# 应用程序中使用 ADODB COM 对象,该应用程序是在 Windows 2008 R2 标准 64 位上开发的。现在我已经使用 Windows 2008 Standard 64 位(不是 R2)将应用程序移动到产品服务器上,现在出现以下错误。我的产品机器上似乎没有安装 MDAC 2.8?我找不到任何关于如何在 Windows 2008 计算机上安装 MDAC 2.8 的参考,也许有人可以指出我正确的方向?
错误:无法将类型“ADODB.StreamClass”的 COM 对象强制转换为接口类型“ADODB._Stream”。此操作失败,因为对 IID 为“{00001565-0000-0010-8000-00AA006D2EA4}”的接口的 COM 组件上的 QueryInterface 调用由于以下错误而失败:不支持此类接口(来自 HRESULT 的异常:0x80004002 (E_NOINTERFACE)) .,
I am using ADODB COM object in my c# application which is developed on Windows 2008 R2 Standard 64bit. Now I have moved application on prod server with Windows 2008 Standard 64bit(not R2) and now I get error below. It seems MDAC 2.8 is not installed on my prod machine? I can't find any reference how to install MDAC 2.8 on Windows 2008 machine, maybe someone could point me to right direction?
Error: Unable to cast COM object of type 'ADODB.StreamClass' to interface type 'ADODB._Stream'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00001565-0000-0010-8000-00AA006D2EA4}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).,
发布评论
评论(2)
在 Windows Server 2008 R2 SP1 中,ADO COM 接口发生了变化。因此,在 Windows 7 SP1 或 Server 2008 R2 SP1 系统上编译的任何 ADO 应用程序都不能在较旧的操作系统(例如 Server 2008 非 R2)上运行。
以下是描述此问题的知识库文章 (KB2517589) 的链接:
一些解决方法,特别是它链接到一个“兼容性类型库”,您可以使用它在开发计算机上进行编译。
不幸的是,这个问题还没有“真正”的解决方案(这对于 VBA 开发人员来说尤其痛苦,当前唯一的解决方法是在开发计算机上卸载 Windows 7 SP1)。 Microsoft 论坛中有一个线程讨论此问题并发布更新:
更新:与此同时,Microsoft 已发布针对此问题的修复程序。如果您在 Windows 7 SP1/2008R2 SP1 开发计算机上安装以下页面 (KB 2640696) 中的修补程序并重新编译您的应用程序,它将在较旧的操作系统上再次运行:
With Windows Server 2008 R2 SP1, the ADO COM interfaces were changed. As a result, any ADO application compiled on a system with Windows 7 SP1 or Server 2008 R2 SP1 does not run on older operating systems (such as Server 2008 non-R2).
Here's the link to the Knowledge Base article describing this issue (KB2517589):
The article also contains a few workarounds, in particular, it links to a "compatibility typelib" that you can use for compiling on your dev machine.
Unfortunately, there is no "real" solution for this problem yet (which is particularly painful for VBA developers, where the only current workaround is to uninstall Windows 7 SP1 on the dev machine). There is a thread in the Microsoft Forums where this issue is discussed and where updates are posted:
UPDATE: In the meantime, Microsoft has released a fix for this issue. If you install the hotfix from the following page (KB 2640696) on your Windows 7 SP1/2008R2 SP1 development machine and recompile your application, it will work again on older operating systems:
也许您可以尝试以下实用程序来确定它是否真的存在:
MDAC 实用程序:组件检查器
http://www.microsoft.com/download/en/details.aspx ?id=1953
它没有提到 Windows Server 2008,但也许它可以工作...
如果您确定该服务器中没有 ADODB COM 对象,那么您需要安装 MDAC2.8 组件,您也可以从 Microsoft 下载该组件。
链接:http://www.microsoft.com/download/en/details .aspx?id=5793
另外,在 Windows Server 2008 中,您可以转到文件夹:
C:\Program Files\Common Files\System\ado
并检查那里是否有 MDAC 组件。对于 MDAC 2.8,您应该具有:msado28.tlb
您可以使用它来引用 MS OFFe VBA 项目中的 ADODB 对象。
Maybe you can try the following utility to identify if it is really there or not:
MDAC Utility: Component Checker
http://www.microsoft.com/download/en/details.aspx?id=1953
It doesn't mention Windows Server 2008 but maybe it works...
If you are sure there is no ADODB COM object in that server then you need to install the MDAC2.8 components that you can also download from Microsoft.
Link: http://www.microsoft.com/download/en/details.aspx?id=5793
Also, in a Windows Server 2008 you can go to folder:
C:\Program Files\Common Files\System\ado
and check if you have the MDAC components there. For MDAC 2.8 you should have: msado28.tlb
which is the one you can use to reference ADODB objects in a MS OFfice VBA project.