Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Calling a delphi dll from VB.net

Calling a delphi dll from VB.net

Scheduled Pinned Locked Moved .NET (Core and Framework)
comhelpcsharpdelphi
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rijz
    wrote on last edited by
    #1

    Hi all, Please provide steps to call a Delphi dll from vb.net. Any help is very much apprecited. Thanks alot. Following I have tried and no luck. 1) Added the DLL as a refernce to the project. -Shows an error message "Please MAke Sure that the file is accessible , and that it is a valid assembly or COM Component" 2) Used the DllImport method of System.Runtime.InteropServices

    <DllImport("delphiProgram.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)> _
    Public Shared Function TestFunction(ByVal strTif As String) As Long

    -- Runtime it shows an error message "Unable to load DLL 'delphiProgram.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" 3) used the tlbimp.exe to make the dll as an interop -- Shows a message 'delphiProgram.dll' is not a valid type library. Thank you. Regards, Rijz

    D L 2 Replies Last reply
    0
    • R Rijz

      Hi all, Please provide steps to call a Delphi dll from vb.net. Any help is very much apprecited. Thanks alot. Following I have tried and no luck. 1) Added the DLL as a refernce to the project. -Shows an error message "Please MAke Sure that the file is accessible , and that it is a valid assembly or COM Component" 2) Used the DllImport method of System.Runtime.InteropServices

      <DllImport("delphiProgram.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)> _
      Public Shared Function TestFunction(ByVal strTif As String) As Long

      -- Runtime it shows an error message "Unable to load DLL 'delphiProgram.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" 3) used the tlbimp.exe to make the dll as an interop -- Shows a message 'delphiProgram.dll' is not a valid type library. Thank you. Regards, Rijz

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      The .DLL has to be in the same folder as your .EXE or in a folder on the PATH environment variable. Chances are, it's not in either. You can add the .DLL to your project and, in the Properties window under "Copy to Output Directory", make sure it says "Copy Always" so the .DLL ends up in your project Debug or Release folder with your .EXE.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      1 Reply Last reply
      0
      • R Rijz

        Hi all, Please provide steps to call a Delphi dll from vb.net. Any help is very much apprecited. Thanks alot. Following I have tried and no luck. 1) Added the DLL as a refernce to the project. -Shows an error message "Please MAke Sure that the file is accessible , and that it is a valid assembly or COM Component" 2) Used the DllImport method of System.Runtime.InteropServices

        <DllImport("delphiProgram.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Ansi)> _
        Public Shared Function TestFunction(ByVal strTif As String) As Long

        -- Runtime it shows an error message "Unable to load DLL 'delphiProgram.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" 3) used the tlbimp.exe to make the dll as an interop -- Shows a message 'delphiProgram.dll' is not a valid type library. Thank you. Regards, Rijz

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Tested with Lazarus;

        library project1;

        {$mode objfpc}{$H+}

        uses
        Classes;

        procedure DoHelloWorld(var Source: string) stdcall; export;
        begin
        Source := 'Hello world :)';
        end;

        exports DoHelloWorld;

        begin
        end.

        Imports System.Runtime.InteropServices
        Imports System.Text

        Module Module1

         \_
        Public Sub DoHelloWorld(ByRef Source As StringBuilder)
        End Sub
        
        Sub Main()
            Dim sb As New StringBuilder()
            DoHelloWorld(sb)
            Console.WriteLine(sb.ToString())
            Console.ReadKey()
        End Sub
        

        End Module

        Bastard Programmer from Hell :suss:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups