Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error with existing COM Reference or adding a new one

Let me preface this by saying that I am unfamiliar with COM references, and I am using VS2010 on a Windows 7 64 bit machine. This morning I pulled down an existing project from TFS. I then tried to build the project and received this error:

The type or namespace name 'validatecom' could not be found (are you missing a using directive or an assembly reference?)

And I get this warning:

Cannot get the file path for type library "d0b51ccc-aa31-47a1-b3ff-b8ed71c522a1" version 1.0. Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))

When I check the references, sure enough, I see the yellow exclamation in the only COM Reference in the solution. After some fruitless testing, I decided to try adding a new COM Reference.

Add Reference -> COM tab -> random M$ library

This results in a new reference with a yellow exclamation. I try building the project to see if I get the same error. This time I receive this error:

Encountered multiple versions of the assembly with GUID '23d736f1-acbc-11d3-b0e8-00104bff2710'. Try pre-importing one of these assemblies.

And I get this warning:

Cannot find wrapper assembly for type library "ADODB".

I have no idea if these two errors are related. If not, then resolving the first certainly takes precedence over the last.

like image 692
YouGotCSharpInMyJava Avatar asked Jan 09 '13 14:01

YouGotCSharpInMyJava


1 Answers

One other thing to check for is if your COM library is registered in Windows' registery, which can you done like this:

%windir%\system32\regsvr32 YourComLibrary.dll

Next you'll need to create an interop .NET DLL that wraps around the COM library you are trying to reference in your C# project. The way to do this is by running the type library importer utility (use the Visual Studio 2010 command prompt):

tlbimp.exe YourComLibrary.dll /out:YourWrappedComLibrary.dll

As for the ADODB reference, you'll likely need to reference the Primary Interop Assembly for ADO (ADODB). This can be found on your machine at the following location. Add a reference to this and you should be good.

C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies\adodb.dll

Hopefully the above gets you going. Its been too long since I've messed with COM... memory maybe foggy a bit. Enjoy!

like image 91
ajawad987 Avatar answered Sep 23 '22 15:09

ajawad987