How to resolve this error while creating a project using the "First Person" template with C++ optioon selected?

An error occurred while trying to generate project files.

Running C:/Program Files/Epic Games/UE_5.1/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“C:/Users/User/Documents/Unreal Projects/MyProject/MyProject.uproject” -game -rocket -progress
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“C:/Users/User/Documents/Unreal Projects/MyProject/MyProject.uproject” -game -rocket -progress
Log file: C:\Users\User\AppData\Local\UnrealBuildTool\Log_GPF.txt

Some Platforms were skipped due to invalid SDK setup: Android, Linux, LinuxArm64.
See the log file for detailed information

Discovering modules, targets and source code for project…
Binding IntelliSense data…
Binding IntelliSense data… 100%
Writing project files…
Writing project files… 0%
Unhandled exception: System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.
at System.Text.StringBuilder.ToString()
at UnrealBuildTool.VCProjectFile.WriteProjectFile(List1 InPlatforms, List1 InConfigurations, PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProject.cs:line 1381
at UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 2812
at UnrealBuildTool.VCProjectFileGenerator.WriteProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProjectFileGenerator.cs:line 480
at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(PlatformProjectGeneratorCollection PlatformProjectGenerators, String[] Arguments, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1176
at UnrealBuildTool.GenerateProjectFilesMode.Execute(CommandLineArguments Arguments, ILogger Logger) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\GenerateProjectFilesMode.cs:line 233
at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in D:\build++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 648

Hey @EntroPlex1!

The Unhandled exception here is “System.OutOfMemoryException”. This means your PageFile can’t expand enough to create the installation. You need to free up some hard drive space on your system drive (the one with windows installed on it). PageFile is working memory, kind of like RAM expansion onto your ROM. It’s the reason you should leave a certain amount of your hard drive empty, so it has room to expand and contract.

I understood that, but got confused since I have 32 gb of ram and 300 gb of my SSD is free.

Whoaaaa okay. If there’s 300 available on the drive your windows is located… I’m stumped, too. That’s always been the solution I’ve seen for System.OutOfMemoryException :thinking:

Yeah, exactly, that’s super confusing, so that’s the reason I decided to ask it on this forum.

For what it’s worth, I have (very rarely) seen issues where the pagefile.sys is corrupted in such a way that it won’t expand past a certain point.

As far as I know, the only way to fix that is to go to the computer properties in Windows (right click on “This Computer”, pick Properties), go to Advanced System Settings, and pick “Virtual Memory”, then pick “no paging file”. Reboot, and your pagefile.sys will be gone. Go back to the same place as before and change the setting back to “System managed pagefile size.” and reboot again, and you’ll have a fresh pagefile.sys.

I don’t know if that’ll help in your case, but I suppose it can’t hurt…?

Unfortunately that didn’t work, but thanks for trying

Interestingly, this only happens when I try to create C++ project, while blueprint project creation works just fine.

…huh. :confused:

Okay, out of curiosity, which version of Visual Studio do you have installed?

The latest version - Visual Studio 2022.

I saw somewhere that it is recommended to try to update the x86 version of dotnet installed. Any idea how should I do that?

Ironically, I finally ran into this problem myself just the other day; in my case, the issue was that the 32-bit version of dotnet came before the 64-bit version in the path. While UE5.0.3 seems to work fine in this case, UE5.1 will attempt to use the 32-bit version and horf up a hairball.


If you open a command prompt and type where.exe dotnet, if the 32-bit version (e.g. the Program Files (x86) version) is first, that’s likely your problem; just go edit the PATH environment variable (This PC → Properties → Advanced System Properties → Environment Variables) and swap the order of the two.