An Error ocurred while trying to generate project files

Pleas help, I am an absolute noob. When I try to start a new C++ project, I get an error message. If I start a new blueprint project, all works well. Thank all in advance for your kind help. The error I get says the following:

An error occurred while trying to generate project files.

Running E:/Program Files/Epic Games/UE_4.20/Engine/Binaries/DotNET/UnrealBuildTool.exe -projectfiles -project=“F:/Desktop/JPV/UE4/MyProject/MyProject.uproject” -game -rocket -progress
Discovering modules, targets and source code for project…
WARNING: Exception while generating include data for UE4Editor: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object[] args)
at UnrealBuildTool.BuildException…ctor(String Format, Object[] Arguments) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\BuildException.cs:line 39
at UnrealBuildTool.VCEnvironment.Create(WindowsCompiler Compiler, CppPlatform Platform, String CompilerVersion, String WindowsSdkVersion) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCEnvironment.cs:line 500
at UnrealBuildTool.VCToolChain…ctor(CppPlatform Platform, ReadOnlyTargetRules Target) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs:line 31
at UnrealBuildTool.WindowsPlatform.CreateToolChain(CppPlatform CppPlatform, ReadOnlyTargetRules Target) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\UEBuildWindows.cs:line 1599
at UnrealBuildTool.UEBuildTarget.CreateToolchain(CppPlatform CppPlatform) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2429
at UnrealBuildTool.UEBuildTarget.Build(BuildConfiguration BuildConfiguration, CPPHeaders Headers, List1 OutputItems, List1 UObjectModules, ISourceFileWorkingSet WorkingSet, ActionGraph ActionGraph, EHotReload HotReload, Boolean bIsAssemblingBuild) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2012
at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 1737
at UnrealBuildTool.ProjectFileGenerator.GenerateIntelliSenseData(String[] Arguments, List1 Targets) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1736 Binding IntelliSense data... 0%@progress 'Binding IntelliSense data...' 33% WARNING: Exception while generating include data for StudioEditor: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.Format(String format, Object[] args) at UnrealBuildTool.BuildException..ctor(String Format, Object[] Arguments) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\BuildException.cs:line 39 at UnrealBuildTool.VCEnvironment.Create(WindowsCompiler Compiler, CppPlatform Platform, String CompilerVersion, String WindowsSdkVersion) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCEnvironment.cs:line 500 at UnrealBuildTool.VCToolChain..ctor(CppPlatform Platform, ReadOnlyTargetRules Target) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs:line 31 at UnrealBuildTool.WindowsPlatform.CreateToolChain(CppPlatform CppPlatform, ReadOnlyTargetRules Target) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\UEBuildWindows.cs:line 1599 at UnrealBuildTool.UEBuildTarget.CreateToolchain(CppPlatform CppPlatform) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2429 at UnrealBuildTool.UEBuildTarget.Build(BuildConfiguration BuildConfiguration, CPPHeaders Headers, List1 OutputItems, List1 UObjectModules, ISourceFileWorkingSet WorkingSet, ActionGraph ActionGraph, EHotReload HotReload, Boolean bIsAssemblingBuild) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2012 at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 1737 at UnrealBuildTool.ProjectFileGenerator.GenerateIntelliSenseData(String[] Arguments, List1 Targets) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1736
Binding IntelliSense data… 33%@progress ‘Binding IntelliSense data…’ 67%
WARNING: Exception while generating include data for MyProjectEditor: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.Format(String format, Object[] args)
at UnrealBuildTool.BuildException…ctor(String Format, Object[] Arguments) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\BuildException.cs:line 39
at UnrealBuildTool.VCEnvironment.Create(WindowsCompiler Compiler, CppPlatform Platform, String CompilerVersion, String WindowsSdkVersion) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCEnvironment.cs:line 500
at UnrealBuildTool.VCToolChain…ctor(CppPlatform Platform, ReadOnlyTargetRules Target) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs:line 31
at UnrealBuildTool.WindowsPlatform.CreateToolChain(CppPlatform CppPlatform, ReadOnlyTargetRules Target) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\UEBuildWindows.cs:line 1599
at UnrealBuildTool.UEBuildTarget.CreateToolchain(CppPlatform CppPlatform) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2429
at UnrealBuildTool.UEBuildTarget.Build(BuildConfiguration BuildConfiguration, CPPHeaders Headers, List1 OutputItems, List1 UObjectModules, ISourceFileWorkingSet WorkingSet, ActionGraph ActionGraph, EHotReload HotReload, Boolean bIsAssemblingBuild) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Configuration\UEBuildTarget.cs:line 2012
at UnrealBuildTool.UnrealBuildTool.RunUBT(BuildConfiguration BuildConfiguration, String[] Arguments, FileReference ProjectFile, Boolean bCatchExceptions) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 1737
at UnrealBuildTool.ProjectFileGenerator.GenerateIntelliSenseData(String[] Arguments, List1 Targets) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 1736 Binding IntelliSense data... 67%@progress 'Binding IntelliSense data...' 100% ERROR: UnrealBuildTool Exception: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.Format(String format, Object[] args) at UnrealBuildTool.BuildException..ctor(String Format, Object[] Arguments) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\BuildException.cs:line 39 at UnrealBuildTool.VCEnvironment.Create(WindowsCompiler Compiler, CppPlatform Platform, String CompilerVersion, String WindowsSdkVersion) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCEnvironment.cs:line 500 at UnrealBuildTool.VCToolChain.GetVCIncludePaths(CppPlatform Platform, WindowsCompiler Compiler, String CompilerVersion) in D:\Build\++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Platform\Windows\VCToolChain.cs:line 1697 at UnrealBuildTool.VCProjectFile.WriteProjectFile(List1 InPlatforms, List`1 InConfigurations) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProject.cs:line 494
at UnrealBuildTool.ProjectFileGenerator.WriteProjectFiles() in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 2475
at UnrealBuildTool.VCProjectFileGenerator.WriteProjectFiles() in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\VisualStudio\VCProjectFileGenerator.cs:line 377
at UnrealBuildTool.ProjectFileGenerator.GenerateProjectFiles(String[] Arguments) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\ProjectFiles\ProjectFileGenerator.cs:line 963
at UnrealBuildTool.UnrealBuildTool.GuardedMain(String[] Arguments) in D:\Build++UE4\Sync\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 899

I managed to fix it! Not thanks to any of you guys. If anyone encounters the same problem, you need to unisnatll UE4, the launcher and all versions of visual studio, then reinstall UE4 and everything starts working again. Good luck!

I’m also having this problem, but no amount of re-installing seems to be helping.
Any more advice you have would be awesome.

Modify your Visual Studio to support C#, the build process requires C# as well as C++

I think you meant the other way around! You need to add C++ support to Visual Studio. Here’s a link to a Microsoft doc to help you with that: Install C and C++ support in Visual Studio | Microsoft Learn

Btw I was running into this same issue and adding C++ support to Visual Studio as per the help doc worked for me