如何在Visual Basic 6.0中使用在Visual Basic 2008中创建的dll [英] How can I use a dll created in Visual Basic 2008 in Visual Basic 6.0

查看:73
本文介绍了如何在Visual Basic 6.0中使用在Visual Basic 2008中创建的dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Basic 2008中创建了一个dll,但是当尝试在使用V​​isual Basic 6.0(regsvr32)的计算机上注册时,抛出有关缺少模块的错误.

请帮助

I create a dll in visual basic 2008 but when trying to register on a computer with Visual Basic 6.0 (regsvr32), throw an error about a missing module.

Please help

推荐答案

阅读本文,确保已实现所有必需的步骤

向COM公开.NET组件 [
Read this article, make sure you have implemented all of the required steps

Exposing .NET Components to COM[^]


似乎您正在使用控件或.客户计算机上不存在的DLL.您的库正在使用哪些外部.DLL?
It seems that you''re library uses a control or .DLL that isn''t present on the customer machines. What external .DLL''s is your library using?


将.NET程序集打包为COM组件是可行的,但是它有很多缺点.有更有效的技术可以将托管方法直接导出为非托管方法,因此.NET程序集可以像任何其他非托管DLL一样由非托管代码使用,例如,由VB使用.

通常认为这是不可能的.但是这是错误的.这仅在C#或VB.NET中是不可能的,但使用IL汇编程序则完全有可能.这是CLR ECMA和ISO标准的一部分,不像任何肮脏的把戏.

因此,其想法是使用特殊属性将要导出的方法标记为非托管方法.该代码由VB.NET或C#编译,反汇编;然后根据属性修改IL代码,然后重新组装.这是使用MSBuild定制步骤自动完成的,因此不需要IL汇编程序知识.

您可以在以下CodeProject文章中找到解决方案:
非托管代码可以包装托管方法 [如何自动将.NET功能导出到非托管程序 [
Packaging .NET assembly as COM component works, but it has many downsides. There are more effective techniques which allows to directly export managed methods as unmanaged, so the .NET assembly could be used by the unmanaged code like any other unmanaged DLL, for example, by VB.

It is commonly believed that this is impossible. But this is not true. It is only impossible in C# or VB.NET, but quite possible using IL assembler; and this is a part of CLR ECMA and ISO standards, not like any dirty trick.

So, the idea is to use a special attribute to mark the methods to be exported as unmanaged. The code is complied by VB.NET or C#, disassembled; then the IL code is modified according to the attributes and assembled again. This is automated using the MSBuild custom step, so no knowledge of IL assembler is required.

You can find the solution in the following CodeProject articles:
Unmanaged code can wrap managed methods[^],
How to Automate Exporting .NET Function to Unmanaged Programs[^].

—SA


这篇关于如何在Visual Basic 6.0中使用在Visual Basic 2008中创建的dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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