简体   繁体   English

将VB6 ActiveX DLL引用添加到VS2008项目

[英]Add a VB6 ActiveX DLL reference to a VS2008 project

At work, we have a VB6 project (ActiveX DLL) that we need to be able to add as a reference to another VS2008 C# project. 在工作中,我们有一个VB6项目(ActiveX DLL),我们需要能够添加它作为另一个VS2008 C#项目的参考。

A developer there tells me that in the past, they have been able to do so but now we made a change to the VB6 DLL and had to recompile it. 那里的开发人员告诉我,在过去,他们已经能够这样做,但现在我们对VB6 DLL进行了更改,并且必须重新编译它。

As such, we need to update the reference in the VS2008 project but when we try to add the reference to the VB6 DLL back (after removing the old reference) to the VS2008 project, we get a yellow "!" 因此,我们需要更新VS2008项目中的引用,但是当我们尝试将对VB6 DLL的引用(在删除旧引用之后)添加到VS2008项目时,我们得到一个黄色的“!” icon on the newly added reference and then when we build, VS2008 says the reference cannot be found. 在新添加的引用上的图标,然后在我们构建时,VS2008表示无法找到引用。

I tried the "Browse" and "COM" tabs where you can add reference, no luck. 我尝试了“浏览”和“COM”选项卡,您可以在其中添加引用,没有运气。

Do we need some kind of TLB to be able to add it or something ? 我们是否需要某种TLB才能添加它?

Thanks. 谢谢。

You need to do the following from a command prompt: 您需要从命令提示符执行以下操作:

#CD to wherever the dll is located
regsrv32 /u foo.dll
regsrv32 foo.dll

This will unregister the old com object and register the new one. 这将取消注册旧的com对象并注册新的com对象。

He's right, you could do that from command prompt. 他是对的,你可以从命令提示符那样做。

Remember though, your Active-X control DLL could be 16-bit, so use 但请记住,您的Active-X控件DLL可能是16位,因此请使用

    regsrv /u foo.dll
    regsrv foo.dll

from command prompt. 从命令提示符。 But 32-bit works fine for regsrv32! 但32位适用于regsrv32!

I used OLE/COM object viewer (included in Windows SDK 6.0A) then I saw a bunch of COM entries in "All objects" ie: MyDLLName.className and some were pointing to a DLL file which did not exist anymore. 我使用了OLE / COM对象查看器(包含在Windows SDK 6.0A中)然后我在“所有对象”中看到了一堆COM条目,即:MyDLLName.className和一些指向不再存在的DLL文件。 Deleted all the relevant COM entries in the Windows registry that pointed to the deleted DLL and left all the ones which pointed to the existing DLL and then I could import it successfully in my VC# project. 删除了Windows注册表中指向已删除的DLL的所有相关COM条目,并将所有指向现有DLL的条目留下,然后我可以在VC#项目中成功导入它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM