error MSB4018: The "VCMessage" task failed unexpectedly. 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.AppendFormat(IFormatProvider provider, String format, Object[] args) at System.String.Format(IFormatProvider provider, String format, Object[] args) at Microsoft.Build.Shared.ResourceUtilities.FormatString(String unformatted, Object[] args) at Microsoft.Build.Utilities.TaskLoggingHelper.FormatString(String unformatted, Object[] args) at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args) at Microsoft.Build.Utilities.TaskLoggingHelper.LogWarningWithCodeFromResources(String messageResourceName, Object[] messageArgs) at Microsoft.Build.CPPTasks.VCMessage.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets 990 6 vtk_minimal
-
what exactly were you compiling? And did that only happen after you added/edited something? – TheGeekZn Aug 16 '12 at 10:20
-
an c++ code. actually I installed visual studio. then build vtk library on it. now I'm trying to test it with an example code I found on internet. it does not work. before this, I was trying to handle LNK2019, LNK1120. I thought there's a problem with linker. – TahaYusuf Aug 16 '12 at 10:49
-
You might be trying too much at once. That code might be old or wrong. Its up to the person who wrote it to help / update. – TheGeekZn Aug 16 '12 at 11:03
-
I obtained the same issue when building ITK 4.3.1 – sergtk Apr 11 '13 at 17:38
-
If go to the error list window and click on the error you may get more information. In my case it pointed to a line in Microsoft.CppCommon.targets which was an XML element. In the arguments attribute one value was %(Link.ProgramDatabaseFile) which was not set and causing the problem. – Fredrick May 22 '17 at 15:25
2 Answers
I had the same problem. I had an old Visual Studio 2005 C++ project, which I reopened with Visual Studio 2010 C++. For me, the first suggestion proposed at Microsoft Connect worked:
The issue stems from the unexpected $(TargetDir) found in the property page under Link->OutputFile. During the build process, we tried to expand the OutputFile to a fullpath but only got an empty value. Thus, it led to the index out-of-bound exception.
It is unlikely we will be able to fix these before VS2010 release. The workaround is to correct OutputPath or inherit from parent.
Right-click on the project and go to Properties > Linker > General. Then set "Output File" to "<Inherit from parent or project defaults>"
Hope that fixes it for you too.

- 789
- 8
- 34
-
1Excellent, I changed the Output file path and change it back the way it was, and it started working for all solutions. – Kiran Pagar Sep 17 '14 at 19:39
I could not figure out what was wrong. The only thing that fixed this error for me was to remove the configuration and create a new one. So in Configuration Manager I removed the one that would not build, and I recreated it from a similar one.

- 5,045
- 3
- 21
- 24