2

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

Tomas
  • 17,551
  • 43
  • 152
  • 257

2 Answers2

4

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:

Heinzi
  • 167,459
  • 57
  • 363
  • 519
  • This is the right answer. Installing 2008 R2 SP1 should be considered as the solution. – Hans Passant Jul 19 '11 at 10:32
  • @Hans: His production machine is 2008 *non-R2*. – Heinzi Jul 19 '11 at 10:36
  • I have searched for solution the whole day and it seems upgrade to 2008 R2 is the right step. All other solutions which I have found are vague and not reliable. – Tomas Jul 19 '11 at 14:07
  • @Tomas: Sounds good, just remember that you need 2008 R2 **SP1**. – Heinzi Jul 19 '11 at 14:17
  • The alternative to upgrading 2008 (or if you are using 2003) is to use `dynamic` to force late-binding. E.g., replace `CDO.Message msg = new CDO.Message();ADODB.Stream strm = msg.GetStream();` with `dynamic msg = new CDO.Message();dynamic strm = msg.GetStream();`. This is what "method 2" is recommending in the KB Heinzi references. – Brian Dec 12 '11 at 18:49
1

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.

Carlos Quintanilla
  • 12,937
  • 3
  • 22
  • 25
  • I have tried to use that utility but do not understand how to use it, very complex. Also was trying to install drivers from you link suggested but nothing happens. I start installation package, see unzipping files progress and then nothing. I do not get any error message or installation confirmation message. Also this installation package was created in 2005 and Windows 2008 is not listed as supported OS. – Tomas Jul 19 '11 at 09:47
  • That's right. It doesn't mention Server 2008 which means that it is unsupported as stated here: http://msdn.microsoft.com/en-us/library/ms810810.aspx so you will need to change your program to use ADO.NET instead of Interop COM. – Carlos Quintanilla Jul 19 '11 at 10:21
  • I'm wondering what components does VBA uses in MS Office installed on a Windows Server 2008 or even Win 7 to connect to a DB if MDAC is not supported on it. – Carlos Quintanilla Jul 19 '11 at 10:24
  • @Carlos: MS Offices uses MDAC. Since Vista, MDAC (now called Windows DAC) is included as part of the operating system and updated as part of the operating system update. See http://en.wikipedia.org/wiki/MDAC – Heinzi Jul 19 '11 at 10:34