# Unhandled exception: BadImageFormatException: Bad IL format. The format of the file 'XXXModuleRules.dll' is invalid. 

**URL:** <https://forums.unrealengine.com/t/unhandled-exception-badimageformatexception-bad-il-format-the-format-of-the-file-xxxmodulerules-dll-is-invalid/2493634>\
**Category:** C++\
**Tags:** unreal-engine, question\
**Created:** [May 6, 2025, 2:57pm UTC](https://forums.unrealengine.com/t/unhandled-exception-badimageformatexception-bad-il-format-the-format-of-the-file-xxxmodulerules-dll-is-invalid/2493634 "2025-05-06T14:57:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsi6800](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tsi6800](https://forums.unrealengine.com/u/tsi6800)\
**Post date:** [May 6, 2025, 2:57pm UTC](https://forums.unrealengine.com/t/unhandled-exception-badimageformatexception-bad-il-format-the-format-of-the-file-xxxmodulerules-dll-is-invalid/2493634/1 "2025-05-06T14:57:54Z")

</div>

When I try to create a blank C++ project I got the following error:

Unhandled exception: BadImageFormatException: Bad IL format. The format of the file ‘C:\work\Unreal Projects\QuickStart\Intermediate\Build\BuildRules\QuickStartModuleRules.dll’ is invalid.

Seems like a problem with .Net. To be sure that the right .Net versions are installed I consulted  
[Unreal Engine 5.5 Release Notes | Unreal Engine 5.5 Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/unreal-engine/unreal-engine-5.5-release-notes)  
and found the following:

- .NET 4.6.2 Targeting Pack
- .NET 8.0  
I installed just that on my machine and removed other .Net versions but still get the same failure.  
The exact failure from the console:

Running C:/Program Files/Epic Games/UE\_5.5/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“C:/work/Unreal Projects/QuickStart/QuickStart.uproject” -game -rocket -progress  
Using bundled DotNet SDK version: 8.0.300  
Running UnrealBuildTool: dotnet “....\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“C:/work/Unreal Projects/QuickStart/QuickStart.uproject” -game -rocket -progress  
Log file: C:\Users\XXX\AppData\Local\UnrealBuildTool\Log\_GPF.txt

Generating VisualStudio project files:  
Discovering modules, targets and source code for project…  
Available x64 toolchains (1):

- C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808  
(Family=14.43.34808, FamilyRank=1, Version=14.43.34810, Is64Bit=True, ReleaseChannel=Latest, Architecture=x64)  
Visual Studio 2022 compiler version 14.43.34810 is not a preferred version. Please use the latest preferred version 14.38.33130  
Total execution time: 1.32 seconds  
Unhandled exception: BadImageFormatException: Bad IL format. The format of the file ‘C:\work\Unreal Projects\QuickStart\Intermediate\Build\BuildRules\QuickStartModuleRules.dll’ is invalid.  
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)  
at System.Reflection.Assembly.LoadFile(String path)  
at UnrealBuildTool.DynamicCompilation.CompileAssembly(FileReference OutputAssemblyPath, IEnumerable`1 SourceFileNames, ILogger Logger, IEnumerable`1 ReferencedAssembies, IEnumerable`1 PreprocessorDefines, Boolean TreatWarningsAsErrors) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs:line 289 at UnrealBuildTool.DynamicCompilation.CompileAndLoadAssembly(FileReference OutputAssemblyPath, IEnumerable`1 SourceFileNames, ILogger Logger, IEnumerable`1 ReferencedAssembies, IEnumerable`1 PreprocessorDefines, Boolean DoNotCompile, Boolean ForceCompile, Boolean TreatWarningsAsErrors) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs:line 351  
at UnrealBuildTool.RulesAssembly..ctor(RulesScope Scope, IReadOnlyList`1 BaseDirs, IReadOnlyList`1 Plugins, IReadOnlyDictionary`2 ModuleFileToContext, IReadOnlyList`1 TargetFiles, FileReference AssemblyFileName, Boolean bContainsEngineModules, Nullable`1 DefaultBuildSettings, Boolean bReadOnly, Boolean bSkipCompile, Boolean bForceCompile, RulesAssembly Parent, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 191 at UnrealBuildTool.RulesCompiler.<>c __DisplayClass9_0.<CreateProjectRulesAssembly>b__ 0(FileReference _) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs:line 332 at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at UnrealBuildTool.RulesCompiler.CreateProjectRulesAssembly(FileReference ProjectFileName, Boolean bUsePrecompiled, Boolean bSkipCompile, Boolean bForceCompile, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs:line 247 at UnrealBuildTool.ProjectFileGenerator.AddProjectsForAllTargets(PlatformProjectGeneratorCollection PlatformProjectGenerators, List`1 AllGames, List`1 AllTargetFiles, String[] Arguments, List`1 EngineProjects, List`1 GameProjects, Dictionary`2 ProjectFileToUProjectFile, Dictionary`2 ProgramProjects, Dictionary`2 RulesAssemblies, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 2791  
at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String Arguments, Boolean bCacheDataForEditor, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1048  
at UnrealBuildTool.GenerateProjectFilesMode.ExecuteAsync(CommandLineArguments Arguments, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\GenerateProjectFilesMode.cs:line 260  
at UnrealBuildTool.UnrealBuildTool.Main(String ArgumentsArray) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 687

Can anyone help me with this issue?

Thank you very much

---

<div class="post-metadata">

**Author:** ![brs-sebascova](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brs-sebascova/32/1228079_2.png) [@brs-sebascova](https://forums.unrealengine.com/u/brs-sebascova)\
**Post date:** [May 6, 2025, 6:21pm UTC](https://forums.unrealengine.com/t/unhandled-exception-badimageformatexception-bad-il-format-the-format-of-the-file-xxxmodulerules-dll-is-invalid/2493634/2 "2025-05-06T18:21:21Z")

</div>

Hello there @tsi6800!

You are on the right track. Your updated log after the .Net installs has the following call:

> _Visual Studio 2022 compiler version 14.43.34810 is not a preferred version. Please use the latest preferred version 14.38.33130_

This means that your current Visual Studio build is either missing components, or its using invalid ones. You can follow the installation guide from the community, which can be found here:

> **[Setting Up Visual Studio Development Environment for C++ Projects in Unreal...](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine)**
>
> Tips, tricks, and techniques for setting up Visual Studio to work with Unreal Engine.

Additionally, another thread has a detailed explanation for the compiler setup, please follow the steps included:

> [@Packaging error 'detected compiler newer than visual studio 2022' - beginner](https://forums.unrealengine.com/t/packaging-error-detected-compiler-newer-than-visual-studio-2022-beginner/2174644/17):
>
> Hello readers, this is a summary of this thread and how to set-up the compiler for unreal engine and avoid errors, solved by: @Arodi007 and @villinx You will need visual studio installer and visual studio 2022 downloaded in order for unreal engine to be able to compile and package your game build. You must download the SDK (software developement tool) and MSVC (microsoft visual compiler) from visual studio installer. Press ‘modify’ there are tabs at the top, press ‘individual c…

---

<div class="post-metadata">

**Author:** ![tsi6800](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@tsi6800](https://forums.unrealengine.com/u/tsi6800)\
**Post date:** [May 7, 2025, 12:29pm UTC](https://forums.unrealengine.com/t/unhandled-exception-badimageformatexception-bad-il-format-the-format-of-the-file-xxxmodulerules-dll-is-invalid/2493634/3 "2025-05-07T12:29:40Z")

</div>

Hello brs-sebascova

Thank you for your quick reply. Following your advice I could remove the warning

Visual Studio 2022 compiler version 14.43.34810 is not a preferred version. Please use the latest preferred version 14.38.33130

by selecting this version in the Visual Studio Installer

 ![MSVC_14.38-17.8_Screenshot 2025-05-07 141225](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/b/d/1bd371a2d05b51c9316379adad427420a7f5b7e2.png)

I also follow the installation instructions from

[Setting Up Visual Studio Development Environment for C++ Projects in Unreal Engine | Unreal Engine 5.5 Documentation | Epic Developer Community](https://dev.epicgames.com/documentation/en-us/unreal-engine/setting-up-visual-studio-development-environment-for-cplusplus-projects-in-unreal-engine)

and install the designated versions MSVC, Windows SDK, LLVM, .Net, added the required workloads and added the required components

 ![VS_Setup_Unreal5.5_Screenshot 2025-05-07 141803](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/8/7/d87030e940016038ead43ca4d4dfff4b452eacaf.png)

I also updated the BuildConfiguration.xml under C:\Users\XXX\AppData\Roaming\Unreal Engine\UnrealBuildTool as suggested in

[Packaging error ‘detected compiler newer than visual studio 2022’ - beginner - Development / Programming & Scripting - Epic Developer Community Forums](https://forums.unrealengine.com/t/packaging-error-detected-compiler-newer-than-visual-studio-2022-beginner/2174644)

```auto
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="https://www.unrealengine.com/BuildConfiguration">
<WindowsPlatform>
<CompilerVersion>14.38.33130</CompilerVersion>
<ToolchainVersion>14.38.33130</ToolchainVersion>
</WindowsPlatform>
</Configuration>

```

I restarted my system to be sure that all packages are loaded fresh but nevertheless when I want to create a new blank C++ Project in Unreal I still got the BadImageFormatException.

The recent log looks like that:

Running C:/Program Files/Epic Games/UE\_5.5/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“C:/work/Unreal Projects/QuickStart/QuickStart.uproject” -game -rocket -progress  
Using bundled DotNet SDK version: 8.0.300  
Running UnrealBuildTool: dotnet “....\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“C:/work/Unreal Projects/QuickStart/QuickStart.uproject” -game -rocket -progress  
Log file: C:\Users\XXX\AppData\Local\UnrealBuildTool\Log\_GPF.txt

Generating VisualStudio project files:  
Discovering modules, targets and source code for project…  
Total execution time: 1.38 seconds  
Unhandled exception: BadImageFormatException: Bad IL format. The format of the file ‘C:\work\Unreal Projects\QuickStart\Intermediate\Build\BuildRules\QuickStartModuleRules.dll’ is invalid.  
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)  
at System.Reflection.Assembly.LoadFile(String path)  
at UnrealBuildTool.DynamicCompilation.CompileAssembly(FileReference OutputAssemblyPath, IEnumerable`1 SourceFileNames, ILogger Logger, IEnumerable`1 ReferencedAssembies, IEnumerable`1 PreprocessorDefines, Boolean TreatWarningsAsErrors) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs:line 289 at UnrealBuildTool.DynamicCompilation.CompileAndLoadAssembly(FileReference OutputAssemblyPath, IEnumerable`1 SourceFileNames, ILogger Logger, IEnumerable`1 ReferencedAssembies, IEnumerable`1 PreprocessorDefines, Boolean DoNotCompile, Boolean ForceCompile, Boolean TreatWarningsAsErrors) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\DynamicCompilation.cs:line 351  
at UnrealBuildTool.RulesAssembly..ctor(RulesScope Scope, IReadOnlyList`1 BaseDirs, IReadOnlyList`1 Plugins, IReadOnlyDictionary`2 ModuleFileToContext, IReadOnlyList`1 TargetFiles, FileReference AssemblyFileName, Boolean bContainsEngineModules, Nullable`1 DefaultBuildSettings, Boolean bReadOnly, Boolean bSkipCompile, Boolean bForceCompile, RulesAssembly Parent, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesAssembly.cs:line 191 at UnrealBuildTool.RulesCompiler.<>c __DisplayClass9_0.<CreateProjectRulesAssembly>b__ 0(FileReference _) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs:line 332 at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) at UnrealBuildTool.RulesCompiler.CreateProjectRulesAssembly(FileReference ProjectFileName, Boolean bUsePrecompiled, Boolean bSkipCompile, Boolean bForceCompile, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\RulesCompiler.cs:line 247 at UnrealBuildTool.ProjectFileGenerator.AddProjectsForAllTargets(PlatformProjectGeneratorCollection PlatformProjectGenerators, List`1 AllGames, List`1 AllTargetFiles, String[] Arguments, List`1 EngineProjects, List`1 GameProjects, Dictionary`2 ProjectFileToUProjectFile, Dictionary`2 ProgramProjects, Dictionary`2 RulesAssemblies, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 2791  
at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String Arguments, Boolean bCacheDataForEditor, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1048  
at UnrealBuildTool.GenerateProjectFilesMode.ExecuteAsync(CommandLineArguments Arguments, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\GenerateProjectFilesMode.cs:line 260  
at UnrealBuildTool.UnrealBuildTool.Main(String ArgumentsArray) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 687

For me the setup looks like suggested, do you have another hint for me?

I would appreciate that a lot.

Thanks

---

<div class="post-metadata">

**Author:** ![brs-sebascova](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/brs-sebascova/32/1228079_2.png) [@brs-sebascova](https://forums.unrealengine.com/u/brs-sebascova)\
**Post date:** [May 7, 2025, 1:45pm UTC](https://forums.unrealengine.com/t/unhandled-exception-badimageformatexception-bad-il-format-the-format-of-the-file-xxxmodulerules-dll-is-invalid/2493634/4 "2025-05-07T13:45:34Z")

</div>

Hello again!

That’s good, the compiler error is gone, now we just need to sort out “BadImageFormatException”. Since the error call aims at **QuickStartModuleRules.dll** , the process is most likely clashing with with corrupt or missing elements tied to .NET assembly.

As first approach, please test deleting the Intermediate and Binaries folders, then regenerate the project files. If the issue remains active after that, delete the DerivedDataCache, and repeat the process.

Alternatively, since you are currently working with .NET 8.0.300, it would be worth a shot downgrading to .NET 6.0, which is currently the recommended version for UE5 ([Download .NET 6.0 (Linux, macOS, and Windows) | .NET](https://dotnet.microsoft.com/en-us/download/dotnet/6.0)).
