.net注册的dll在vb6中不显示功能 [英] .net registered dll does not show function in vb6
问题描述
net dll(PasswordHashLibrary)。创建项目后,我转到项目属性-> build->注册COM互操作。
net dll (PasswordHashLibrary) to be used in vb6 application. after creating the project, i went to project properties -> build -> Register for COM interop.
然后使用regasm命令将此dll注册到我的计算机上。
开始一个新的vb6项目->添加对PasswordHashLibrary的引用
Then registered this dll on my machine using regasm command. Started a fresh vb6 project -> added reference to PasswordHashLibrary
现在vb6项目允许我编写以下内容
Now the vb6 project allows me to write the following
Dim objHash As New PasswordHashLibrary.Hash
- PasswordHashLibrary =名称空间
- 哈希=类
我不能在其中调用任何函数(类和函数是公共的)
But it doesn't let me call any functions inside (class and functions are public)
例如,我有一个静态函数
for instance i have a static function
PasswordHashLibrary.Hash.HashPassword( abc)
PasswordHashLibrary.Hash.HashPassword("abc")
它给出了编译时错误
未找到方法或数据成员
method or data member not found
当我尝试调试并在对象浏览器中查看时,没有成员
When i try to debug and look in object browser there is no member present
我的完整.Net代码
namespace PasswordHashLibrary
{
public class Hash
{
private const int PBKDF2IterCount = 1000; // default for Rfc2898DeriveBytes
private const int PBKDF2SubkeyLength = 256 / 8; // 256 bits
private const int SaltSize = 128 / 8; // 128 bits
public static string HashPassword(string password)
{
//my code goes here
}
}
}
推荐答案
我删除了静态属性,并添加了完成该操作的接口!
I removed the static attribute and added an interface that did the trick!
namespace PasswordHashLibrary
{
public interface ComClassInterface
{
}
public class Hash : ComClassInterface
{
private const int PBKDF2IterCount = 1000; // default for Rfc2898DeriveBytes
private const int PBKDF2SubkeyLength = 256 / 8; // 256 bits
private const int SaltSize = 128 / 8; // 128 bits
//[ComVisible(true)]
public string HashPassword(string password)
{
//my code goes here
}
}
}
这篇关于.net注册的dll在vb6中不显示功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!