{"record":{"id":"8c994d778ca300b8","repo":"lucasg/Dependencies","slug":"loading-module-0-s-failed","errorCode":null,"errorMessage":"Loading module {0:s} failed.","messagePattern":"Loading module (.+?) failed\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"DependenciesGui/App.xaml.cs","lineNumber":62,"sourceCode":"            {\n                mainWindow.AppStatusBarMessage.Content = (object)StatusBarMessage;\n            }\n        }\n\n        public PE LoadBinary(string path)\n        {\n            StatusBarMessage = String.Format(\"Loading module {0:s} ...\", path);\n\n\t\t\tif (!NativeFile.Exists(path))\n\t\t\t{\n\t\t\t\tStatusBarMessage = String.Format(\"Loading PE file \\\"{0:s}\\\" failed : file not present on disk.\", path);\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tPE pe = BinaryCache.LoadPe(path);\n            if (pe == null || !pe.LoadSuccessful)\n            {\n                StatusBarMessage = String.Format(\"Loading module {0:s} failed.\", path);\n            }\n            else\n            {\n                StatusBarMessage = String.Format(\"Loading PE file \\\"{0:s}\\\" successful.\", pe.Filepath);\n            }\n            \n            return pe;\n        }\n\n        void App_Startup(object sender, StartupEventArgs e)\n        {\n            (Application.Current as App).PropertyChanged += App_PropertyChanged;\n\n            Phlib.InitializePhLib();\n\n\t\t\t// Load singleton for binary caching\n\t\t\tBinaryCache.InitializeBinaryCache(Dependencies.BinaryCacheOption.GetGlobalBehaviour() == Dependencies.BinaryCacheOption.BinaryCacheOptionValue.Yes);\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/lucasg/Dependencies/blob/1997a40000b77bd3326cbc33672a7b9f78bb23f3/DependenciesGui/App.xaml.cs#L44-L80","documentation":"Status message set by App.LoadBinary (DependenciesGui/App.xaml.cs:62) when BinaryCache.LoadPe returns null OR a PE whose LoadSuccessful is false. Per BinaryCache.LoadPe's contract (DependenciesLib/BinaryCache.cs:66-68), null means not found and LoadSuccessful==false means the file exists but is not a valid PE. LoadBinary still returns the (failed) pe object rather than null in the LoadSuccessful==false case.","triggerScenarios":"Opening a file in DependenciesGui that exists but fails phlib parsing, or whose cached load yields a non-loadable PE.","commonSituations":"Same kinds of inputs as error 9 (non-PE, truncated, wrong architecture) but reached through the GUI; also stale cache entries when `-cache` mode is on.","solutions":["Verify the file is a valid PE with another tool (dumpbin, PE-bear).","If using the binary cache, disable it (Options->Properties->Binary cache = No) and retry to rule out a stale cached copy.","Re-download/rebuild the binary if truncated or corrupted."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Distinguish the two LoadBinary failure modes by re-checking LoadSuccessful.\nPE pe = (Application.Current as App).LoadBinary(path);\nif (pe == null)\n{\n    // file not present on disk (error 10 path)\n    return;\n}\nif (!pe.LoadSuccessful)\n{\n    // file present but not a valid PE - LoadBinary still returns the failed pe\n    Console.Error.WriteLine($\"{path} is not a valid PE\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember LoadBinary returns a non-null but failed PE when the file exists but is unparseable - always also test LoadSuccessful.","Disable the binary cache when diagnosing load failures to avoid stale cached PEs."],"tags":["gui","load-failure","status-bar","binary-cache"],"backgroundTag":null,"analyzedSha":"1997a40000b77bd3326cbc33672a7b9f78bb23f3","analyzedAt":"2026-08-13T18:14:41.696Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}