none
System.DllNotFoundException: 'Unable to load DLL 'UnManaged.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)' RRS feed

  • Question

  • I am developing a Visual C# Desktop Application in Visual Studio 2017. I have a third party unmanaged DLL which I have to access from my code. I am using the following line of code.

    [DllImport("unManaged.dll")]

    public static extern int GetVersion();

    The build is successful but during runtime, I am getting the mentioned error.

    The dependency DLLs are : JLinkLPC11.dll, KERNEL32.dll, USER32.dll, ADVAPI32.dll. 

    JLinkLPC11.dll has dependency on  KERNEL32.dll, USER32.dll, ADVAPI32.dll, WINMM.dll.

    I have all the DLLs in the project folder. 

    I already tried the following:

    1. Changed the build configuration to x86 since the DLL was created using x86 machine.
    2. Put the DLL in system32 folder.
    3. Put the DLL path in system path.

    I am not able to figure out the error. any help?


    • Edited by KaiBattousai Wednesday, August 1, 2018 1:45 PM remove unwanted characters
    Wednesday, August 1, 2018 1:43 PM

Answers

  • Hi Wendy,

    Sorry to bother you. But after updating my Microsoft Visual C++ 2017 Redistributable (x86 and x64), it seems to be working now.

    • Marked as answer by KaiBattousai Thursday, August 2, 2018 6:25 PM
    Thursday, August 2, 2018 2:00 PM

All replies

  • Hi KaiBattousai,

    Thank you for posting here.

    According to your description, I have some simple questions to confirm with you.

    Have you placed all the unmanaged assembly in correct folder? Including the dependency dlls? It seems that the application could not find the unmanaged dll, so it could not be loaded. and check the system path. Please try to use absolute path when you load the dll using DllImport.

    Another possible root cause is the platform option that you compiled the unmanaged dll with. May I know the OS of development PC? And the platform option? Does the third party unmanaged dll provider support the x86 platform? Please confirm with dll provider. 

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 2, 2018 7:01 AM
    Moderator
  • Hi Wendy,

    Sorry to bother you. But after updating my Microsoft Visual C++ 2017 Redistributable (x86 and x64), it seems to be working now.

    • Marked as answer by KaiBattousai Thursday, August 2, 2018 6:25 PM
    Thursday, August 2, 2018 2:00 PM
  • For the future, it will really help if you put everything relevant in the body of the question. You put the error message in the title but not the body.

    You say you put the DLL in the project folder but that won't work. The project folder is not the default folder during execution. The default folder (for C#) is either bin\Debug or bin|Release, depending on which configuration you are executing.

    The build uses the lib file but never the dll file. Execution uses the dll file but never the lib file. So the build was able to find the lib file I assume because it looks in the project directory by default.



    Sam Hobbs
    SimpleSamples.Info

    Thursday, August 2, 2018 5:44 PM
  • Hi Wendy, 

    Sorry to bother you. I'm having the same trouble you have experienced. 

    I still get the error that I can't load the dll file even though i have a dll file in the specified folder. 

    I want to know if you have solved the problem and how to solve it. 

    Thanks, 

    Tuesday, March 12, 2019 5:35 AM