Error while loading unmanaged dll written in C into visual studio 2019

0

I am getting error “System.DllNotFoundException:

Unable to load DLL 'swedll32.dll': Invalid access to memory location. (Exception from HRESULT: 0x800703E6)'

while Form1 loads. That dll is a 32 bit native or unmanaged dll written in C. I am using 64 bit Windows 10 and visual studio 2019. I tried many ways but no result.

I tried in this ways: Disable DEP and UAC, Run VS 2019 as Administrator, Compile – Target CPU – any CPU to X86

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)

  End Class

   Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load        

    swe_set_ephe_path(System.IO.Path.GetDirectoryName(Application.ExecutablePath) & "\SwEph")

   End Sub
.net
vb.net
visual-studio-2019
asked on Stack Overflow Dec 19, 2020 by user12647598 • edited Dec 19, 2020 by Lajos Arpad

1 Answer

-1

Whenever you get this kind of error message, you should know that a dll is missing.

Find the file

You need to have swedll32.dll somewhere on your disk. If it's not found,, then download it.

Adding the dll

Now, assuming that you already have the dll, you will need to add it to your project. Now, if you are using Visual Studio, as your tags suggest, then you will need to navigate to Project -> Add Reference and choose Add Reference. Browse to the dll file and add it to the project. Read more here.

answered on Stack Overflow Dec 19, 2020 by Lajos Arpad

User contributions licensed under CC BY-SA 3.0