# 5.1 Error when creating new C++ template project

**URL:** <https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932>\
**Category:** C++\
**Tags:** unreal-engine, UE5-0, CPP, question\
**Created:** [November 16, 2022, 11:20am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932 "2022-11-16T11:20:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![swagentrotz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/swagentrotz/32/464913_2.png) [@swagentrotz](https://forums.unrealengine.com/u/swagentrotz)\
**Post date:** [November 16, 2022, 11:20am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/1 "2022-11-16T11:20:37Z")

</div>

I just tried to create a new C++ test project based on the ThirdPerson example project and received the error below. Please note that I can create new C++ projects in 4.27.2 and 5.0.3 on this PC without any issues.

```auto
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:/Projects/PerforceDepot/ThirdPersonTest/ThirdPersonTest.uproject" -game -rocket -progress
Running UnrealBuildTool: dotnet "..\..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll" -projectfiles -project="C:/Projects/PerforceDepot/ThirdPersonTest/ThirdPersonTest.uproject" -game -rocket -progress
Log file: C:\Users\sascha\AppData\Local\UnrealBuildTool\Log_GPF.txt

Some Platforms were skipped due to invalid SDK setup: IOS, 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.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC_ALLOC_FLAGS flags)
   at System.GC.<AllocateUninitializedArray>g__AllocateNewUninitializedArray|66_0[T](Int32 length, Boolean pinned)
   at System.Text.StringBuilder.ExpandByABlock(Int32 minBlockCharCount)
   at System.Text.StringBuilder.Append(Char* value, Int32 valueCount)
   at System.Text.StringBuilder.AppendHelper(String value)
   at System.Text.StringBuilder.Append(String value)
   at UnrealBuildTool.VCProjectFile.AppendIncludePaths(StringBuilder Builder, IncludePathsCollection Collection, HashSet`1 IgnorePaths) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProject.cs:line 825
   at UnrealBuildTool.VCProjectFile.WriteProjectFile(List`1 InPlatforms, List`1 InConfigurations, PlatformProjectGeneratorCollection PlatformProjectGenerators, ILogger Logger) in D:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProject.cs:line 1251
   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

```

---

<div class="post-metadata">

**Author:** ![MhmdRida](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mhmdrida/32/465501_2.png) [@MhmdRida](https://forums.unrealengine.com/u/MhmdRida)\
**Post date:** [November 16, 2022, 5:11pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/2 "2022-11-16T17:11:29Z")

</div>

Same Issue !!

---

<div class="post-metadata">

**Author:** ![Onoa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Onoa](https://forums.unrealengine.com/u/Onoa)\
**Post date:** [November 17, 2022, 1:58am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/3 "2022-11-17T01:58:22Z")

</div>

Having the same issue. I posted the issue in the 5.1 Release Announcement thread, but no one has replied so far. Glad to have confirmation that I’m not the only one having this issue.

> [@Unreal Engine 5.1 Released](https://forums.unrealengine.com/t/unreal-engine-5-1-released/691237/29):
>
> I’m getting the following error when trying to generate project files for my 5.0.3 C++ project: Binding IntelliSense data… 100% Writing project files… Writing project files… 0% Unhandled exception: System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown. at System.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC\_ALLOC\_FLAGS flags) at System.GC.g\_\_AllocateNewUninitializedArray|66\_0[T](Int32 length, Boolean pinned) at System.Text.StringBuilde…

I also created a thread on the subject.

> [@Is anyone able to create a new C++ project or generate C++ project files with 5.1?](https://forums.unrealengine.com/t/is-anyone-able-to-create-a-new-c-project-or-generate-c-project-files-with-5-1/692339):
>
> I’m getting the following error when trying to generate project files for my 5.0.3 C++ project: Binding IntelliSense data… 100% Writing project files… Writing project files… 0% Unhandled exception: System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown. at System.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC\_ALLOC\_FLAGS flags) at System.GC.g\_\_AllocateNewUninitializedArray|66\_0[T](Int32 length, Boolean pinned) at System.Text.StringBuilde…

---

<div class="post-metadata">

**Author:** ![MhmdRida](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mhmdrida/32/465501_2.png) [@MhmdRida](https://forums.unrealengine.com/u/MhmdRida)\
**Post date:** [November 17, 2022, 11:22am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/4 "2022-11-17T11:22:53Z")

</div>

![Fix UE5 build](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/b/5/8b50bb6b893a27a10a6f9bd764fad445e2da1701.png)  
installing the .NET SDK fixed the issue

---

<div class="post-metadata">

**Author:** ![PresumptivePanda](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/presumptivepanda/32/1194593_2.png) [@PresumptivePanda](https://forums.unrealengine.com/u/PresumptivePanda)\
**Post date:** [November 17, 2022, 11:38pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/5 "2022-11-17T23:38:25Z")

</div>

This topic has been moved from **international** to **Programming & Scripting: C++**.

When posting, please review the categories to ensure your topic is posted in the most relevant space. Hopefully, the category change of this topic will help to get you answers or help others in the future. 🙂

Thanks so much for being a part of the Unreal Engine community!  
-Panda

---

<div class="post-metadata">

**Author:** ![Onoa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Onoa](https://forums.unrealengine.com/u/Onoa)\
**Post date:** [November 18, 2022, 2:23am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/6 "2022-11-18T02:23:29Z")

</div>

Didn’t work for me unfortunately. Would you mind listing / sharing all the components that you have installed for VS 2019?

Here’s my install:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/6/3/163ff51d0e893c6c73727a2d484199f92f021bde.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/9/d/f9d45ea5393889a65d9b834f5522fecccd431346.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/6/eb650ad4ec6df58f042b9d79e7bf0f9eba0f97ba.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/8/7/f8744805dfb217278207041e222e01b2a15de817.png)

These install settings are based on the official documentation for 5.1 and with this install, I am able to create new 5.0 C++ projects and generate project files. But I get the crash for 5.1.

> **[Setting Up Visual Studio](https://docs.unrealengine.com/5.1/en-US/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

Thanks!

---

<div class="post-metadata">

**Author:** ![Demonrras](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Demonrras](https://forums.unrealengine.com/u/Demonrras)\
**Post date:** [November 23, 2022, 10:21pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/7 "2022-11-23T22:21:59Z")

</div>

Same issue here too…don’t know how to fix it…

---

<div class="post-metadata">

**Author:** ![Demonrras](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Demonrras](https://forums.unrealengine.com/u/Demonrras)\
**Post date:** [November 23, 2022, 10:23pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/8 "2022-11-23T22:23:21Z")

</div>

Don’t work here

---

<div class="post-metadata">

**Author:** ![AActor\_424](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aactor_424/32/630972_2.png) [@AActor\_424](https://forums.unrealengine.com/u/AActor_424)\
**Post date:** [November 25, 2022, 1:23am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/9 "2022-11-25T01:23:17Z")

</div>

In case you get an error code 6 from VS 2019, check that you have installed all the required tools, given by the docs:

> **[Setting Up Visual Studio](https://docs.unrealengine.com/5.1/en-US/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

Verify the tools below are installed:

- C++ profiling tools
- C++ AddressSanitizer
- Windows 10 SDK (10.0.18362 or Newer)
- Unreal Engine installer"

You can check by open “Visual Studio Installer” and go to the tab “Workloads” and then select “Desktop Development with C++” (naming may be a little bit different).

In my case _Windows 10 SDK (10.0.18362 or Newer)_ was not installed by default when I installed VS 2019.

I just had to install the Windows 10 SDK and then I restarted my computer. Also, check that you have enough disk space in your C:/user/username/AppData/UnrealEngine (or just C:/ drive)

After doing this, I was able to setup a fresh (empty) C++ project in UE 5.1.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Demonrras](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Demonrras](https://forums.unrealengine.com/u/Demonrras)\
**Post date:** [November 25, 2022, 6:44pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/10 "2022-11-25T18:44:05Z")

</div>

They update the page about setting the visual studio for unreal engine adding 5.1 with new specific requisites and now it’s working!!!🥳 👍🏻

---

<div class="post-metadata">

**Author:** ![Onoa](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Onoa](https://forums.unrealengine.com/u/Onoa)\
**Post date:** [November 28, 2022, 2:18am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/11 "2022-11-28T02:18:56Z")

</div>

This is what fixed it for me:

> [@My c++ project fails to load, but blueprints works fine in UE5](https://forums.unrealengine.com/t/my-c-project-fails-to-load-but-blueprints-works-fine-in-ue5/695325/8):
>
> I am using VS 2022 - 17.4.1 These are the installed components And options [image] [image] My Windows version is 10.0.22621 When I was trying to fix the issue I noticed, that my .NET was installed in C:\programs\dotnet and i still had an old sdk version in C:\programs (x86)\dotnet. I then copied the newer sdk over. Maybe that will fix the problem for you aswell.

---

<div class="post-metadata">

**Author:** ![henrihaka1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/henrihaka1/32/597879_2.png) [@henrihaka1](https://forums.unrealengine.com/u/henrihaka1)\
**Post date:** [November 28, 2022, 4:45pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/12 "2022-11-28T16:45:56Z")

</div>

None of the fixes worked for me. With engine version 5.03 everything works fine, but with 5.1 it can create only blueprint projects. As soon as c++ project template is chosen it keeps giving this error. I’ve tried to add also a c++ class into a blueprint project but still fails and says it cannot compile. I have every tool listed in 5.1 release notes and still do not understand why it fails. Does somebody else have the same issue or maybe resolved it already?  
This is the error message on project creation:  
Running P:/UE\_5.1/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“C:/Users/user/Documents/Unreal Projects/MyProject6/MyProject6.uproject” -game -rocket -progress  
The system cannot find the path specified.  
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“C:/Users/user/Documents/Unreal Projects/MyProject6/MyProject6.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… 100%

Doesn’t output any exception or log file at all. I’ve run out of ideas.

---

<div class="post-metadata">

**Author:** ![ZenLeviathan](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/zenleviathan/32/551307_2.png) [@ZenLeviathan](https://forums.unrealengine.com/u/ZenLeviathan)\
**Post date:** [November 28, 2022, 5:01pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/13 "2022-11-28T17:01:40Z")

</div>

@henrihaka1  
It could definitely be a .NET Core issue. My best solution for this is to either update it usually, but I noticed on mine that my .NET was installed in C:\programs\dotnet and I still had an old SDK version in C:\programs (x86)\dotnet, and copied the newer SDK over.  
I hope this can help you, this seems to be a common issue!  
-Zen

---

<div class="post-metadata">

**Author:** ![henrihaka1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/henrihaka1/32/597879_2.png) [@henrihaka1](https://forums.unrealengine.com/u/henrihaka1)\
**Post date:** [November 28, 2022, 5:21pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/14 "2022-11-28T17:21:01Z")

</div>

Unfortunatelly I tried that too. I seriously do not get why it is happening. I event tried in my linux machine and there works without a problem. I am currently trying to build the engine from source code right now and hope it works like that but I seriously doubt that. Maybe later I will attach my VS2022 individual componenets so somebody more skilled than me can catch where the error might be.  
Thanks for your repply anyway!

---

<div class="post-metadata">

**Author:** ![henrihaka1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/henrihaka1/32/597879_2.png) [@henrihaka1](https://forums.unrealengine.com/u/henrihaka1)\
**Post date:** [November 28, 2022, 5:49pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/15 "2022-11-28T17:49:05Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/5/1/551c4fdb1708260d80fc854630e45c06da79eacf.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/8/e/d8e3f1297c78fd08e07cc3c5639a89d490c82de1.png)  
Also I just made sure to paste C:/Program Files/dotnet into C:Program Files (x86). Still no result and same error.

---

<div class="post-metadata">

**Author:** ![swagentrotz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/swagentrotz/32/464913_2.png) [@swagentrotz](https://forums.unrealengine.com/u/swagentrotz)\
**Post date:** [November 28, 2022, 10:22pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/16 "2022-11-28T22:22:48Z")

</div>

After installing .net, uwp and development with C++ it worked for me 👍

 ![UE5-1_VS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/e/c/5ec5139d48757363bf489e546e0fb27b80c6f961.png)

---

<div class="post-metadata">

**Author:** ![henrihaka1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/henrihaka1/32/597879_2.png) [@henrihaka1](https://forums.unrealengine.com/u/henrihaka1)\
**Post date:** [November 28, 2022, 11:39pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/17 "2022-11-28T23:39:28Z")

</div>

Unfortunatelly I still have no luck. For any other unlocky guy like me a temporary workaround (that actally works for me) might be to create your project manually and build from cmd P:\UE\_5.1\Engine\Build\BatchFiles\Build.bat MyProjectEditor Win64 Development -Project=“C:\Users\user\Desktop\ueProject\myProject\myProject.uproject” -WaitMutex -FromMsBuild

---

<div class="post-metadata">

**Author:** ![henrihaka1](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/henrihaka1/32/597879_2.png) [@henrihaka1](https://forums.unrealengine.com/u/henrihaka1)\
**Post date:** [November 29, 2022, 12:27am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/18 "2022-11-29T00:27:23Z")

</div>

If it doesn’t bother you much, could you upload the individual components you have selected pls?

---

<div class="post-metadata">

**Author:** ![Alaska\_is\_mine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Alaska\_is\_mine](https://forums.unrealengine.com/u/Alaska_is_mine)\
**Post date:** [December 12, 2022, 1:27am UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/19 "2022-12-12T01:27:05Z")

</div>

I was having this issue also where I had the dependancies installed but could not generate the files for a template.

Fixed it by changing the dotnet environment variable to be in the correct order. Moved the x64 sdk variable to the top.

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/5/4/8544ca093ac4b68027413cc14088297b33276bf4.png)

---

<div class="post-metadata">

**Author:** ![Philipe.SK](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Philipe.SK](https://forums.unrealengine.com/u/Philipe.SK)\
**Post date:** [December 13, 2022, 11:48pm UTC](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932/20 "2022-12-13T23:48:16Z")

</div>

I have Visual Studio 2022 (all dependencies installed) and Unreal 5.1.  
If I want to create a new C++ project from Blank or any other template I get:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/9/ab9414325ed2396c5c2143935736a13725e5fa02.png)

[Next page](https://forums.unrealengine.com/t/5-1-error-when-creating-new-c-template-project/691932.md?page=2)
