The application was unable to start correctly (0xc000007b)

415,477

Solution 1

Normally we get the 0xC000007B error-code (which means STATUS_INVALID_IMAGE_FORMAT), if:

  • If a 32-bit app tried to load a 64-bit DLL.
  • Or if a 64-bit app tried to load a 32-bit DLL.

To really know, I would suggest to test whether there is a problem between your application and its dependencies using dependency walker

Note that all you need to do is open your App using said tool, and issues appear as red log-entries at buttom of screen.

(At least, at time of writting, namely 2022)

Also, make sure you run the correct version of Dependency Walker, for example, the x86 version will display incorrect results when openning x64 binaries.

Solution 2

A load time dependency could not be resolved. The easiest way to debug this is to use Dependency Walker. Use the Profile option to get diagnostics output of the load process. This will identify the point of failure and should guide you to a solution.

The most common cause of this error is trying to load a 64 bit DLL into a 32 bit process, or vice versa.

Solution 3

It is a missing dll. Possibly, your dll that works with com ports have an unresolved dll dependence. You can use dependency walker and windows debugger. Check all of the mfc library, for example. Also, you can use nrCommlib - it is great components to work with com ports.

Solution 4

I tried all the things specified here and found yet another answer. I had to compile my application with 32-bit DLLs. I had built the libraries both in 32-bit and 64-bit but had my PATH set to 64-bit libraries. After I recompiled my application (with a number of changes in my code as well) I got this dreaded error and struggled for two days. Finally, after trying a number of other things, I changed my PATH to have the 32-bit DLLs before the 64-bit DLLs (they have the same names). And it worked. I am just adding it here for completeness.

Solution 5

It has been mentioned in earlier answers that using dependency walker is the way to go, in my case (my application keeps failing with the error code), dependency walker showed a few dll that are NOT relevant!

Finally figured out that I can run profiling by going to "profile" menu and it will run the application and stop at the exact dll that's cause the problem! I found out a 32bit dll was picked because of path and fixed it.

enter image description here

Share:
415,477

Related videos on Youtube

Mawg says reinstate Monica
Author by

Mawg says reinstate Monica

Donate a cup of food for free: Click to Give @ The Hunger Site SOreadytohelp

Updated on April 19, 2022

Comments

  • Mawg says reinstate Monica
    Mawg says reinstate Monica about 2 years

    I have a client/server app which I have been developing on a single PC. Now it needs two serial ports, so I borrowed a PC from a friend.

    When I build my app and try to run or debug it (whether in the Delphi IDE or from Windows File manager), it errors "The application was unable to start correctly (0xc000007b)".

    Googling doesn't bring up much, but seems to indicate that this is nothing Delphi specific and happens with other apps. It seems to be caused by calling into a 32 bit DLL from a 64 bit app or vice versa.

    • both PCs are Windows 7, 64 bit
    • both have Delphi Xe2 starter edition which can only handle 32 bits
    • The app runs fine on my PC, but not on my friend's
    • Other Delphi apps run just fine on both PCs

    Can anyone give me a hint as to how to track this down?

    • Remy Lebeau
      Remy Lebeau about 12 years
      On a side note, you can use com0com to install virtual serial ports on a single PC. Great for debugging and testing, just create 2 virtual ports and link them together in the config, then run your apps on each port so they can talk to each other.
    • Luis Carrasco
      Luis Carrasco about 12 years
      Did you check the Windows Events Log? Sometimes Windows provides more information regarding which DLL made the app fail.
    • Alex
      Alex about 12 years
      It will be a missing DLL I suspect, usually some utility, or even the memory manager.
    • David Heffernan
      David Heffernan about 12 years
      @mj2008 Missing DLL gives a different error: The program can't start because XXXX.dll is missing from your computer. Try reinstalling the program to fix this problem.
    • Rudy Velthuis
      Rudy Velthuis over 9 years
      FWIW: Read this answer in another forum. It explains what could be going on.
    • EntangledLoops
      EntangledLoops about 9 years
      @DavidHeffernan That's not always true. Just now I encountered a situation where removing a GTK+ related dll generated this error with no information. Took an hour to figure it out because I made your assumption.
    • David Heffernan
      David Heffernan about 9 years
      @snd This error is STATUS_INVALID_IMAGE_FORMAT. You don't get that when the system cannot find a DLL of that name. You get STATUS_INVALID_IMAGE_FORMAT when a DLL can be found, but it is corrupt, or has the wrong bitness.
  • mox
    mox about 12 years
    based on the Windows Error Codes (google.de/…), this Error Code means: 0xC000007B STATUS_INVALID_IMAGE_FORMAT.
  • David Heffernan
    David Heffernan about 12 years
    This is almost certainly an error reported by the loader and thus occurs before the process starts. Hence debugging would not be an option. Of course, I may be wrong in my diagnosis that the error is raised by the loader.
  • Remy Lebeau
    Remy Lebeau about 12 years
    Which is a good indication that the 32-bit app tried to load a 64-bit DLL.
  • mox
    mox about 12 years
    As a matter of fact, this Error Code Pdf File is an excellent source.
  • Mawg says reinstate Monica
    Mawg says reinstate Monica about 12 years
    +1 and the aswer. Thanks, dependancy walker saved the day. I replaced a 64 bit DLL with a 32 bit version and it works now.
  • Andreas Haferburg
    Andreas Haferburg about 11 years
    Make sure you got the correct version of Dependency Walker. The x86 depends will display incorrect results for x64 binaries.
  • Christian Severin
    Christian Severin almost 10 years
    @jojodmo: actually, "For me it was because the project path was too long" seems to me to be a valid contribution to the bug hunt...
  • Harini Sampath
    Harini Sampath almost 10 years
    mox's and @RemyLebeau's responses should be an answer on its own right.
  • Seyed Morteza Kamali
    Seyed Morteza Kamali over 7 years
    thanks but I can't find problem in my log file.this is link of my log file please check it and tell me what I need for solving unreal 0xc000007b error
  • liorda
    liorda over 6 years
    +1. Also note that you should run the 32 bit version of dependency walker, and ensure that all loaded DLLs are 32 bit. If you try to run the 64 bit version dependency walker, it will happily load the 64 bit DLLs, such as VCRedist, even if your also have their 32 bit versions.
  • IInspectable
    IInspectable over 6 years
    The common controls are part of the operating system. The operating system knows, where to load the correct version from. This does nothing to solve the OP's issue. It doesn't even install a dependency. All it does is compile a manifest resource into the application to use version 6 of the common controls. The preprocessor conditional is also not needed. Simply set processorArchitecture='*', and that's all there is to it.
  • ddfnfal
    ddfnfal almost 6 years
    many thanks for pointing a way to find the error code. I got this same error (wind 8.1 x64) and then installed "Win64 OpenSSL v1.0.2o" , copied libeay32.dll and ssleay32.dll (I already copied pthreadVC2.dll). Finally installed "Microsoft Visual C++ 2010 Redistributable Package (x86)". Then again reinstalled "mosquitto-1.4.15a-install-win32" setup and solved my issue.
  • Victoria
    Victoria almost 6 years
    "Windows XP is no longer the OS" made my day :D
  • Mawg says reinstate Monica
    Mawg says reinstate Monica almost 6 years
    But I asked this question back in '12 - did Windows apps even have manifests then?
  • mistertodd
    mistertodd almost 6 years
    @Mawg This may or not be related to your issue. But with Stackoverflow being a combination of wiki and reddit for knowledge; it's a good tidbit to know for the exact error you reported. Having said that, Windows apps have had assembly manifests going back to Windows 2000; and starting with Windows XP you would no longer get the latest version of comctl32.dll unless your assembly manifest declared a dependency on it.
  • hotblack944
    hotblack944 over 4 years
    @mox - PDF link no longer works - use this one instead winprotocoldoc.blob.core.windows.net/productionwindowsarchiv‌​es/…