VS 2012.3 Referencing MS Access COM DLL, could not

2020-04-05 09:07发布

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

2条回答
够拽才男人
2楼-- · 2020-04-05 09:34

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

查看更多
闹够了就滚
3楼-- · 2020-04-05 09:36

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.

查看更多
登录 后发表回答