I am trying to access a .NET class written in c# from a VB6 application. I
exported the Typelib and registered it successfully (RegAsm DotNetClass.dll
/tlb), but my VB program only sees the methods inherited from Object (Equals,
.GetHashCode, GetType and ToString). I would appreciate any guidance I can
get.
Thanks.
This is the code for my c# class.
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace DotNetClass
{
[ClassInterface(ClassInterfaceType.None)]
public class Class1
{
public Class1(){}
public void WriteToFile()
{
using (StreamWriter sw = new StreamWriter("DotNetClass.txt"))
{
sw.WriteLine("In Class1.WriteToFile");
sw.Write("The date is: ");
sw.WriteLine(DateTime.Now);
}
}
}
}
This is the code for my VB project:
Private Sub cmdStart_Click()
Dim c As New DotNetClass.Class1
' Can't see this method
Call c.WriteToFile
End Sub
Casey - 07 Oct 2005 19:49 GMT
I got it to work. I found an article at
http://www.findarticles.com/p/articles/mi_zddvs/is_200504/ai_n13591391 that
walked me through it. I guess it was the strong name and registering the
assembly in the gac that solved my problem.
> I am trying to access a .NET class written in c# from a VB6 application. I
> exported the Typelib and registered it successfully (RegAsm DotNetClass.dll
[quoted text clipped - 36 lines]
> Call c.WriteToFile
> End Sub