现有的COM参考出错或添加了新的COM参考 [英] Error with existing COM Reference or adding a new one

查看:216
本文介绍了现有的COM参考出错或添加了新的COM参考的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我以此开头作为开头,说我不熟悉COM引用,并且我在Windows 7 64位计算机上使用VS2010.今天早上,我从TFS撤下了一个现有项目.然后,我尝试构建项目并收到此错误:

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:

找不到类型或名称空间名称"validatecom"(您是否缺少using指令或程序集引用?)

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

我得到这个警告:

无法获取类型库"d0b51ccc-aa31-47a1-b3ff-b8ed71c522a1" 1.0版的文件路径.图书馆未注册. (来自HRESULT的异常:0x8002801D(TYPE_E_LIBNOTapped))

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

当我检查引用时,果然,在解决方案中唯一的COM引用中看到黄色的惊叹号.经过一些毫无结果的测试之后,我决定尝试添加一个新的COM参考.

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.

添加参考->"COM"标签->随机M $库

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:

使用GUID'23d736f1-acbc-11d3-b0e8-00104bff2710'遇到了该程序集的多个版本.尝试预导入这些程序集之一.

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

我得到这个警告:

找不到类型库"ADODB"的包装程序集.

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.

推荐答案

要检查的另一件事是,您的COM库是否已在Windows的register中注册,您可以这样做:

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

%windir%\system32\regsvr32 YourComLibrary.dll

接下来,您需要创建一个互操作的.NET DLL,该DLL环绕您要在C#项目中尝试引用的COM库.完成此操作的方法是运行类型库导入程序实用程序(使用Visual Studio 2010命令提示符):

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

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

对于ADODB参考,您可能需要参考 ADO互操作主要程序集(ADODB).您可以在以下位置的计算机上找到该文件.添加对此的引用,您应该会很好.

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 程序集\ adodb.dll

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

希望以上内容能助您一臂之力.自从我搞砸了COM以来,时间太长了……内存可能有点模糊.享受吧!

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

这篇关于现有的COM参考出错或添加了新的COM参考的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆