VS 2012.3 Referencing MS Access COM DLL, could not resolve COM reference error
Asked Answered
S

3

9

I created a new Console project in VS2012.3 (32bit exe) and added a COM Type Library reference to Microsoft Access (I tried both 2003 and 2007). The "Microsoft Access" reference shows up in the Add Reference dialog no problem. However, upon closing that dialog VS displays a yellow triangle overlay on the two newly added references, and I get the following build error:

Could not resolve COM reference "4affc9a0-5f99-101b-af4e-00aa003f0f07" version 9.0. Object reference not set to an instance of an object.

My colleagues are able to do this with no problem on their computer. So I'm trying to figure out what could be the problem with my machine. I'm running Windows 8.1, whereas others are running a mix of Windows 8.0 and 7. Any ideas?

Update - Some screen shots: MS Access in OLEView

Add Reference Dialog

VS COM References not found

ADODB Interop Assembly

ADODB GAC

MsADO25.tlb

Missing PrimaryInteropAssemblyName value in Registry

Schema answered 31/10, 2013 at 23:44 Comment(0)
S
19

Problem Solved: I found the solution here: http://support.microsoft.com/kb/823996.
All I had to do was open the "Developer Command Prompt for VS2012", navigate down to the GAC's ADODB folder, then run regasm.exe ADODB.dll. That fixed the entire problem.

At VS 2012 Command Prompt run regasm

Problem solved: VS COM References now found.

Schema answered 8/11, 2013 at 2:14 Comment(3)
Yeah I really hope it helps others! Thanks for all your help and advice... it kept me motivated to not give up.Schema
Wow! Had an issue (just after the Windows 10 november update) with a COM component and the ADODB was also listed with an exclamation mark in my References and doing this fixed everything! Thanks a lot!Marotta
Thanks a lot, this helped me out a bunch. Also see this post, which explains how to run regasm from the command prompt instead of the Developer Command Prompt. #974439Extravagate
P
1

Windows 8.1 comes with the latest .NET 4.5.1 runtime. First, try installing .NET 3.5 (which includes .NET 2.0/3.0 and is not there by default). You can do that via Control Panel/Turn Windows Feartures on and off.

Further, the {4AFFC9A0-5F99-101B-AF4E-00AA003F0F07} GUID suggests you're using Office 2010. The corresponding type library should be found here:

C:\Program Files (x86)\Microsoft Office\Office14\MSACC.OLB

Try opening it with OleView and see if there's any error.

The next step would be check if the primary interop assembly (PIA) for Access, Microsoft.Office.Interop.Access.dll, has been correctly installed. It should be found under:

C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Access\

Finally, you can try repairing your Office 2010 installation (which should re-register the type library), re-install Office 2010 PIAs, and finally install the latest VSTO Runtime (apparently, that link is still the latest for VS2013).

Preconcerted answered 4/11, 2013 at 2:44 Comment(9)
Thanks for the suggestions. I verified that .NET 3.5 is installed. The GUID is actually the same for several versions of Office. See my new screen-shot above (hopefully it shows) to see what OLEView shows. So it is the exact same GUID for Access 2003, 2007, 2010. I do get an error when attempting to open the C:\Program Files (x86)\Microsoft Office\Office11\MSACC.OLB file: IMoniker::BindToObject failed ... Bad extension for file MK_E_INVALIDEXTENSION($800401E6). The Microsoft.Office.Interop.Access 11.0.0.0 is in indeed in the GAC. I tried reinstalling Access 2003, still have problem.Schema
@LeeGrissom, looks like your MSACC.OLB is not properly registered or corrupted. Grab it from a collegue's machine and try to re-register. There used to be REGTLIB.EXE utility for that. MS removed it from Win8, but you can get it from any Win7 machine: C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exePreconcerted
@LeeGrissom, here's another possible reason: Office 2003 applications are not compatible with Windows 8Preconcerted
I re-registered the MSACC.OLB using regtlibv12.exe and rebooted. It didn't seem to help. Yeah officially Access 2003 isn't supported on Win8, but two of my colleagues have it working. But I'm running Win8.1, so maybe it's hopeless. I sincerely appreciate your help so far... I'm very grateful.Schema
Today, instead of focusing on Access, I focused on understanding why the ADODB reference isn't working. I attached 4 new screen-shots to the post showing my findings. I compared it with my Windows 7 VM (which works great). Two things are different: (1) The size of the adodb.dll is larger on Win8.1 (even though the version claims to be identical). (2) In the Registry on Win8.1, the registry value "PrimaryInteropAssemblyName" is missing from all the TypeLib version keys. See screen-shot for example.Schema
ADODB PIA used to be a part of Office 2003 PIAs (support.microsoft.com/kb/897646/en-us), try installing O2003pia.exe from there. Also, this may help. I don't think I can help any better than that.Preconcerted
Yeah the O2003PIA.exe is the one I tried, several times. It indeed installs the ADODB.dll and typelib file/registry. I watched everything happening via ProcessMon and everything is telling me that this should work. I feel like I'm so close.Schema
I found and fixed the problem. While the solution was different from your suggestions, I wish to sincerely thank you for your help, I really appreciated it. (It kept me motivated!). Is there a way to donate points to you? +1 at the very least.Schema
@LeeGrissom, well done! Glad if I helped. No need to donate points, you've already donated the knowledge :)Preconcerted
A
0

First after upgrade my machine from windows 10 to windows 11, the visual studio give me the same error from title of this post. I did the step from Lee Grissom's repply, and still not working.

So, I found a suggestion from the last current comment on this msdn post, from the user Bedford Bob, removing this reference Microsoft ActiveX Data Objects 2.8 Library from the project and building again, and works.

I don't no how, but after adding the reference again (just for test), the project now works, without any problems, lol.

Asperse answered 14/11, 2022 at 17:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.