Graham
Graham

Reputation: 153

Calling a dll function

I am converting from vb5 and have a dll (now converted to VB.NET) which I use for security checks (mysecurity.dll). It contains the class cSecurityCheck and has a few interfaces, as shown in the VB5 code below, which is how I called it in VB5 from my app. I have copied the VB.NET compiled mysecurity.dll to my project's bin directory and added it as a reference to my VB.NET project(project\bin\mysecurity.dll) but in the project calling module (code below) it doesn't recognise CSecurityCheck, saying it has not been defined. How do I call the dll functions? This dll is used by all my programs and when I finally get to distribute them to a client how do I ensure all the installed executables can look at the one single copy of the dll, which contains the registered user's name?

    Dim s As New CSecurityCheck
    s.AppPath = Application.StartupPath()
    If Not s.DateIsValidated Then
        s = Nothing
        End
    End If
    mRegisteredUser = s.RegisteredUser
    mDaysRemaining = s.DaysRemaining
    s = Nothing

Upvotes: 0

Views: 3765

Answers (1)

Hans Passant
Hans Passant

Reputation: 942308

Adding a COM dll to your project automatically creates a namespace for the types in the DLL. Add Imports TheVb5ProjectName at the top of the file.

If you don't know what that name might be (it depends on VB5 project settings) then click the "Show All Files" icon in the Solution Explorer window, open the References node, locate the imported reference. Right-click it and click View in Object Browser.

Upvotes: 2

Related Questions