error whenever I try to create a c++ project

Hi, I keep getting this error when I try to create a c++ project, does anyone know the answer:

An error occurred while trying to generate project files.

Running D:/UE_5.1/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“D:/Unreal Projects/MyProject2/MyProject2.uproject” -game -rocket -progress
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“D:/Unreal Projects/MyProject2/MyProject2.uproject” -game -rocket -progress
Log file: C:\Users\jaber\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.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

Greetings @jaberhammoudeh1

Welcome to the Unreal Engine Community Forums! I’d be happy to take a look at finding the issue with this. I’d like to start with seeing what system specs you’re currently running on the machine that is receiving this error. Another thread I pulled that has a similar error I also found that you might be interested in here. I hope this is helpful! If it’s not resolved from the link, respond back with the specs and we can go from there. Thanks!

Thank you for reaching out, I had put the dotnet file to programs x86 and got this massage after trying to create a c++ project:

An error occurred while trying to generate project files.

Running D:/UE_5.1/Engine/Build/BatchFiles/Build.bat -projectfiles -project=“D:/Unreal Projects/MyProject2/MyProject2.uproject” -game -rocket -progress
Running UnrealBuildTool: dotnet “…..\Engine\Binaries\DotNET\UnrealBuildTool\UnrealBuildTool.dll” -projectfiles -project=“D:/Unreal Projects/MyProject2/MyProject2.uproject” -game -rocket -progress
Failed to load the dll from [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\6.0.24\hostpolicy.dll], HRESULT: 0x800700C1
An error occurred while loading required library hostpolicy.dll from [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App\6.0.24]

here is my pc info:
windows 10
CPU:
Intel(R) Core™ i7-8750H CPU @ 2.20GHz 2.21 GHz
16.0 GB (15.9 GB usable)
64-bit operating system, x64-based processor
GPU:
Intel(R) UHD Graphics 630
NVUDIA GeForce GTX 1050 Ti

Have you tried downloading the newest versions and reinstalling Dotnet itself yet, by chance? The errors listed seem to be revolving around loading files from your dotnet folder.
(I’d also try running UE as administrator prior to downloading/installing the latest Dotnet)