Unable to load Module

So when you get the error:
“The game module ‘MyGame’ could not be loaded. There may be an operating system error or the module may not be properly set up.”
Means that there is a Windows DLL load error. (If you are not at windows, it is OS specific, but you need to figure it out yourself).

When you open your project in visual studio, you can pause the the debugger when the dialog appears. Unfortunately, this code is in core-Unreal, but luckily you can download the debug symbols as described here: https://answers.unrealengine.com/questions/77315/can-epic-release-the-pdb-files-for-each-official-e.html . In the main thread you see that the problem occurs (before the dialog) in the code:
LoadModulesForProject()->LoadLibraryW(Filename); in WindowsPlatformProcess.cpp. Unfortunately they don’t call GetLastError() to find out the exact problem. see suggestion here c++ - LoadLibraryW() failing to load DLL in System32 - Stack Overflow

Now to find out the which DLL is missing you must use the Windows Debugging tool GFLAGS GFlags - Windows drivers | Microsoft Docs. GFlags is included in Debugging Tools for Windows.
Again unfortunately nobody writes down a good manual how to use it. So these are the steps:

  1. Assuming windows 10 (64-bit), and Windows debugging tools are installed. (I don’t know where to get windows debugging tools from. Maybe try Windows SDK archive - Windows app development)

  2. After installing SDK, restart

  3. Then click on the windows icon and type ‘GFLAGS’

  4. Open “Global Flags (X64) - Desktop App”

  5. Enable Show loader snaps in the “Global Flags” dialog in the “System Registry”-tab (second entry, topleft)

  6. restart (Yes you must restart!)

  7. Open visual studio with your unreal project .sln file.

  8. Run it in debug mode (Developer Editor) (Win64)

  9. When the error dialog comes click OK.

  10. The application closes

  11. Now in the visual studio, Go to the Output pane. And select: Show output from: “Debug”

  12. Examine the last line of the output. Somewhere there will be an entry with ERROR in it. Mine read:

    14b0:15ec @ 00131328 - LdrpSearchPath - RETURN: Status: 0xc0000135
    14b0:15ec @ 00131328 - LdrpProcessWork - ERROR: Unable to load DLL: “clAmdFft.Runtime.dll”, Parent Module: “C:\Users\steven\Documents\Unreal Projects\Revaro 4.11\Binaries\Win64\UE4Editor-Revaro.dll”, Status: 0xc0000135
    14b0:15ec @ 00131328 - LdrpLoadDllInternal - RETURN: Status: 0xc0000135
    14b0:15ec @ 00131328 - LdrLoadDll - RETURN: Status: 0xc0000135
    ‘UE4Editor.exe’ (Win32): Unloaded ‘C:\Windows\System32\mfreadwrite.dll’

“clAmdFft.Runtime.dll” This is the DLL that is giving problems. Either install it, the filepath is valid and configured in the project, make sure it is not corrupt and the right version x86/x64.

In my case I added this library myself for the custom code I was using.

Now disable the GFLAGS again, because it will slow down your computer and restart.

5 Likes