简体   繁体   中英

How to import DLL file in vb.net(visual basic) programmatically?

I have 2 files: lib.dll & executor.exe .

lib.dll

Public Module Module1
   Public Function Abc()
      MsgBox("I am dll")
   End Function
End Module

I want to import lib.dll and use its function in executor.exe .
I know lib.dll can be added via visual basic reference ,
But when I place lib.dll in another directory, then it shows errors.
I want to import dll from a path something like as shown below.

imports "C:\Users\root\Desktop\lib.dll"
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
       Module1.Abc()
    End Sub
End Class

You can specify folder where runtime will search for DLLs in .config file using "probing" element.

https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/specify-assembly-location

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM