Results 1 to 4 of 4

Thread: [02/03] Using Unmanged DLL

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    [02/03] Using Unmanged DLL

    Hi all,
    I have a DLL developed using the previous version of VB(Or C++). How can I able to use that dll in my vb.net appilcation ?
    I can able to get the method using that dll in vb application

    Thanks
    Dana
    Please mark you thread resolved using the Thread Tools as shown

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] Using Unmanged DLL

    If it's a COM component then you simply reference it as though it was a .NET assembly. The IDE will generate an Interop assembly, which is a .NET assembly, that actually talks to the COM component.

    If the library exports functions then you just import them exactly as you do for Windows API functions. The DLL will need to be in the same folder as your EXE or in the system32 folder (or equivalent).
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: [02/03] Using Unmanged DLL

    Thanks for the reply Jhon. I already did the first option and it gave the error as

    http://support.microsoft.com/kb/814197

    I am working on that ...
    Please mark you thread resolved using the Thread Tools as shown

  4. #4
    PowerPoster Deepak Sakpal's Avatar
    Join Date
    Mar 2002
    Location
    Mumbai, India
    Posts
    2,424

    Re: [02/03] Using Unmanged DLL

    You can also use CreateObject approach like this:

    I created a Active-X library project named TestLibrary1 in VB6 having Class1 which contains SayHello method that simply display a greet message.
    e.g. Hello Deepak!

    Now in .NET I create I create the object of that vb6 library in run-time.

    Code:
    Public Class Form1
    
        Private Sub Form1_Load( _
            ByVal sender As Object, _
            ByVal e As System.EventArgs _
        ) Handles Me.Load
    
            Dim obj As Object = CreateObject("TestLibrary1.Class1")
            obj.SayHello("Deepak")
        End Sub
    
    End Class

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width