简体   繁体   English

如何在VB6中使用.NET .DLL文件或库?

[英]How do I use a .NET .DLL file or library in VB6?

I'm just wondering if there is something I should know of when doing this or will it work straight out of the bat as long as the .NET framework is installed on the client? 我只是想知道在执行此操作时是否有我应该知道的内容,或者只要在客户端上安装了.NET框架,它是否会直接起作用?

I ask because when I attempted this, VB6's references dialog said "cant register that dll" 我问,因为当我尝试这个时,VB6的引用对话框说“无法注册那个dll”

Thanks 谢谢

There is a project setting "Make assembly COM-Visible" in the "Assembly Information" section. 在“装配信息”部分中有一个项目设置“使装配COM可见”。 Make sure you tick it. 确保勾选它。

Building on the other answers, .NET DLLS, even when they expose COM objects for use, as described in the other answers, DO NOT CONTAIN an embedded typelib so you unfortunately can't use what you're used to when dealing with COM libraries, RegSvr32.exe. 基于其他答案,.NET DLLS,即使它们暴露COM对象以供使用,如其他答案中所述,也不要包含嵌入式类型库,因此遗憾的是,在处理COM库时,您不能使用您习惯使用的内容,RegSvr32.exe。

As Anivas pointed out, you have to use RegAsm.exe to register the .net assembly (the dll), and then VB6 should be able to see it (Add a reference to it in your VB6 project, the use the object browser to check what objects have been exposed). 正如Anivas指出的那样,你必须使用RegAsm.exe来注册.net程序集(dll),然后VB6应该能够看到它(在VB6项目中添加对它的引用,使用对象浏览器来检查)已暴露的物体)。

You have to convert that to a COM dll. 您必须将其转换为COM dll。 Regasm the dll and use it.Use comvisible attribute. 重新使用它并使用它。使用comvisible属性。

A little other information that might be useful: a .Net DLL isn't compiled code, it's written in "Intermediate Language" (IL). 一些可能有用的其他信息:.Net DLL不是编译代码,它是用“中间语言”(IL)编写的。 You may find it interesting to open a .Net DLL with any text editor and look at it. 您可能会发现使用任何文本编辑器打开.Net DLL并查看它会很有趣。

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

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