Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / October 2005

Tip: Looking for answers? Try searching our database.

Problem with VB6 calling a C# Class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Casey - 07 Oct 2005 19:01 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.