Forum Discussion

bill_qu's avatar
bill_qu
Copper Contributor
Feb 14, 2025
Solved

The strange problem of C # program calling C++dll

My C # calls C++DLL and runs it directly in VS2022 without any errors. We use LoadLibrary to load DLLs.
Packaged as. msix package, after installation, click on the icon of the application to run, some DLLs, error message
Error code 126 or 0.
But running this. exe file directly in the installation directory (Windows apps/applications) does not generate any errors.
I don't know where the problem lies now? How to solve it?

  • The most common cause of loadlibrary failure in an MSIX package is that it doesn't know where to look.  For apps that are used to running outside of the package, this is most commonly solved by one of the following:

    1. Add a LoaderSearchOrder extension to the package listing the relative file path of a folder containing the dlls.
    2. Put the dlls either at the root folder of the package, or in the appropriate VFS\SystemX86 and VFS\SystemX64 folders of the package.
  • The most common cause of loadlibrary failure in an MSIX package is that it doesn't know where to look.  For apps that are used to running outside of the package, this is most commonly solved by one of the following:

    1. Add a LoaderSearchOrder extension to the package listing the relative file path of a folder containing the dlls.
    2. Put the dlls either at the root folder of the package, or in the appropriate VFS\SystemX86 and VFS\SystemX64 folders of the package.
  • Crazylarry's avatar
    Crazylarry
    Copper Contributor

    You can just open it up in Notepad and copy/paste the contents here

  • Crazylarry's avatar
    Crazylarry
    Copper Contributor

    Hello. So you are saying that running the application via its shortcut fails, but running it by the EXE directly works? Can you share the AppxManifest.xml of your package?

    • bill_qu's avatar
      bill_qu
      Copper Contributor

      This webpage cannot upload files. Can you tell me your email?
      My email is email address removed for privacy reasons.
      Can you send me an email? I will send you this file.

Resources