Net framework 2.0 dll in VB6 project. The same code in .Net Framework 4.5 (namespace was PasswordHashLibrary instead of PasswordHashLibrary2.0) was working fine on vb6 project but there is something that i am missing this time.
Here is my c# code on .net v2.0
//using statements here
namespace PasswordHashLibrary2._0
{
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)
{
if (password == null)
{
throw new ArgumentNullException("password cannot be null");
}
// Produce a version 0 (see comment above) text hash.
byte[] salt;
byte[] subkey;
var deriveBytes = new Rfc2898DeriveBytes(password, SaltSize, PBKDF2IterCount);
salt = deriveBytes.Salt;
subkey = deriveBytes.GetBytes(PBKDF2SubkeyLength);
var outputBytes = new byte[1 + SaltSize + PBKDF2SubkeyLength];
Buffer.BlockCopy(salt, 0, outputBytes, 1, SaltSize);
Buffer.BlockCopy(subkey, 0, outputBytes, 1 + SaltSize, PBKDF2SubkeyLength);
return Convert.ToBase64String(outputBytes);
}
// some other functions
}
}
In project properties "Register for COM Interop" is checked. In assemblyInfo.cs
[assembly: ComVisible(true)]
after which i registered this dll with regasm
Now on vb6 project this .tlb is available as PasswordHashLibrary2_0 which i added as a reference. My Vb 6 project code is as follows
Private Sub Form_Load()
Dim objHash As New PasswordHashLibrary2_0.Hash
Dim temp As String
temp = objHash.HashPassword("fsfds")
End Sub
When i run this program, objHash is not set as you can see
After i move forward this line vb6 gives me error
Run-time error '-2147024894 (80070002)':
Automation error The system cannot find the file specified