Results 1 to 12 of 12

Thread: Unable to load DLL

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Unable to load DLL

    I have been documentation for a project in C++.
    I'm trying to write it in VB.Net.
    The project contains a DLL - FriDll.dll

    I have the following code:
    Code:
    Declare Function FriDllVersion Lib "FriDll.dll" Alias "DllVersion" () As Integer
    and
    Code:
    MsgBox(FriDllVersion)
    I just (initially) want to display the dll version number to check I can call the dll.

    But I get the message 'Unable to load DLL'

    I have added the dll to the System32 folder, to the project debug folder, to the project using 'add Existing' - but still get the same error.

    Looking at similar questions I have run the Dependency Walker - but wasn't sure if it showed anything missing.

    Any ideas?

    Thank you.

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Unable to load DLL

    Have you attempted to load it as a reference?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Unable to load DLL

    Quote Originally Posted by DavidGraham View Post
    I have been documentation for a project in C++.
    I'm trying to write it in VB.Net.
    The project contains a DLL - FriDll.dll

    I have the following code:
    Code:
    Declare Function FriDllVersion Lib "FriDll.dll" Alias "DllVersion" () As Integer
    and
    Code:
    MsgBox(FriDllVersion)
    I just (initially) want to display the dll version number to check I can call the dll.

    But I get the message 'Unable to load DLL'

    I have added the dll to the System32 folder, to the project debug folder, to the project using 'add Existing' - but still get the same error.

    Looking at similar questions I have run the Dependency Walker - but wasn't sure if it showed anything missing.

    Any ideas?

    Thank you.
    Is the DLL compiled as 32 or 64 bit? Is your VB app configured the same? Does the DLL have any other dependencies that might be missing from the system?

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,597

    Re: Unable to load DLL

    Since this is a C++ dll I'm not sure that what I suggest will work but you can try to use the System.Diagnostics.FileVersionInfo to display the dll version number
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Re: Unable to load DLL

    Quote Originally Posted by dday9 View Post
    Have you attempted to load it as a reference?
    Yes, It says 'a reference to ..... could not be added'.

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Re: Unable to load DLL

    Quote Originally Posted by sapator View Post
    Since this is a C++ dll I'm not sure that what I suggest will work but you can try to use the System.Diagnostics.FileVersionInfo to display the dll version number
    The call to the version number is just one (simple) example of the calls I would like to make.

  7. #7

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Re: Unable to load DLL

    Quote Originally Posted by PlausiblyDamp View Post
    Is the DLL compiled as 32 or 64 bit? Is your VB app configured the same? Does the DLL have any other dependencies that might be missing from the system?
    I'm not sure if it is compiled as 32 or 64 bit.

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Re: Unable to load DLL

    Quote Originally Posted by PlausiblyDamp View Post
    Is the DLL compiled as 32 or 64 bit? Is your VB app configured the same? Does the DLL have any other dependencies that might be missing from the system?
    Looking again at the Dependency Walker it gives a big list of dependencies not found - the list was so big I wasn't sure what to do.
    It says:
    API-MS-WIN-CORE .....
    API-MS-WIN-EVENTING-PROVIDOR .....
    API-MS-WIN-SECURITY .....
    EXT-MS-ONECORE....
    etc.

    Any ideas if I should be including some other references?

  9. #9
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,458

    Re: Unable to load DLL

    Quote Originally Posted by DavidGraham View Post
    Looking again at the Dependency Walker it gives a big list of dependencies not found - the list was so big I wasn't sure what to do.
    It says:
    API-MS-WIN-CORE .....
    API-MS-WIN-EVENTING-PROVIDOR .....
    API-MS-WIN-SECURITY .....
    EXT-MS-ONECORE....
    etc.

    Any ideas if I should be including some other references?
    Where is this dll from? Is it something developed internally or is part of a 3rd party system? Is it normally installed as part of another package or application?

  10. #10

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Re: Unable to load DLL

    Quote Originally Posted by PlausiblyDamp View Post
    Where is this dll from? Is it something developed internally or is part of a 3rd party system? Is it normally installed as part of another package or application?
    It has been developed by a 3rd party and I'm trying to run it. There were instructions on how to include it in a C++ application but not for VB.Net. Looking at the documentation it looks to be 'stand alone'.

  11. #11
    Addicted Member
    Join Date
    Nov 2011
    Posts
    229

    Re: Unable to load DLL

    Just for reference if the library is 64 bit it would normally be found in System32 folder or if it is 32 bit then found in SysWOW64 folder. Whichever folder the dll is placed perhaps try specifically targeting x64 or x86 rather than targeting AnyCPU within the VB app properties.

  12. #12

    Thread Starter
    Member
    Join Date
    Nov 2018
    Location
    Scotland
    Posts
    35

    Re: Unable to load DLL

    Some have suggested using dllImport - but it is not compiling

    Code:
    <DllImport("FRI.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
    I cannot work out what the syntax should be.

    Following I also have:

    Code:
    Declare Function FriDllVersion Lib "FriDll.dll" Alias "DllVersion" () As Integer
    Declare Function FriDllBuild Lib "FriDll.dll" Alias "DllBuild" () As Integer

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width