1

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
8
  • 1
    How to call a method located inside a C# DLL, from VB.Net, with late binding Commented Dec 1, 2019 at 9:54
  • @JQSOFT thanks but this link didn't solved my problem. Commented Dec 1, 2019 at 10:17
  • stackoverflow.com/questions/1373100/… Commented Dec 1, 2019 at 10:20
  • @jmcilhinney thanks but I was asking for vb.net (visual basic) code, NOT C#. Commented Dec 1, 2019 at 10:22
  • 1
    Try: go to the EXE folder and run it as Administrator. Could be a security issue. Also you can edit your post to add what you've tried. Hard to read the code from comments. Commented Dec 1, 2019 at 11:04

1 Answer 1

3

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

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

Sign up to request clarification or add additional context in comments.

2 Comments

this answer is somewhere according to my point that we should able to use DLL from a path, But in my XML file, I didn't find any DLL path.
You did not read that MSDN documentation correctly. It is NOT path to DLL file, but path to folder, where DLL files are. .NET Framework will try to find referenced DLLs in this folder(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.