I am getting error to use C DLL in VB.net

0

I am getting error “System.DllNotFoundException: 'Unable to load DLL 'swedll32.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)'” while Button1.Click. That dll is a native or unmanaged dll written in C. I am using 64 bit Windows 10 and visual studio 2019. Please help. Thanks

 Public Class Form1

Public Declare Sub swe_set_ephe_path Lib "swedll32.dll" Alias "_swe_set_ephe_path@4" (ByVal path As String)
Public Shared Function swe_get_planet_name(ByVal ipl As Int32) As String
    Dim Pointer As IntPtr
    Dim ReturnParam As New StringBuilder(255)
    Dim Result As String

    Pointer = _swe_get_planet_name(ipl, ReturnParam)
    Result = Marshal.PtrToStringAnsi(Pointer)

    Return Result
End Function
Private Sub Button1_Click_2(sender As Object, e As EventArgs) Handles Button1.Click
swe_set_ephe_path(System.IO.Path.GetDirectoryName(Application.ExecutablePath) & "\SwEph")
    
End Sub
End Class
vb.net
asked on Stack Overflow Dec 17, 2020 by user12647598 • edited Dec 19, 2020 by user12647598

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0