如何在Visual Studio 2010中修复错误MSB4018? [英] How do I fix Error MSB4018 in Visual Studio 2010?

查看:219
本文介绍了如何在Visual Studio 2010中修复错误MSB4018?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误MSB4018:"VCMessage"任务意外失败. System.FormatException:索引(从零开始)必须大于或等于零且小于参数列表的大小. 在System.Text.StringBuilder.AppendFormat(IFormatProvider提供程序,字符串格式,Object []参数) 在System.String.Format(IFormatProvider提供程序,字符串格式,Object []参数) 在Microsoft.Build.Shared.ResourceUtilities.FormatString(字符串未格式化,Object []参数) 在Microsoft.Build.Utilities.TaskLoggingHelper.FormatString(字符串未格式化,Object []参数) 在Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(字符串resourceName,Object []参数) 在Microsoft.Build.Utilities.TaskLoggingHelper.LogWarningWithCodeFromResources(String messageResourceName,Object [] messageArgs) 在Microsoft.Build.CPPTasks.VCMessage.Execute() 在Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 在Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost,TaskLoggingContext taskLoggingContext,TaskHost taskHost,ItemBucket存储桶,TaskExecutionMode howToExecuteTask,Boolean& taskResult)中的C:\ Program Files(x86)\ MSBuild \ Microsoft.Cpp \ v4.0 \ Microsoft .CppBuild.targets 990 6 vtk_minimal

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

推荐答案

我遇到了同样的问题.我有一个旧的Visual Studio 2005 C ++项目,并使用Visual Studio 2010 C ++重新打开了该项目.对我而言,在 Microsoft Connect

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:

此问题源于在链接-> OutputFile下的属性页中发现的意外$(TargetDir).在构建过程中,我们尝试将OutputFile扩展为全路径,但只有一个空值.因此,它导致索引越界异常.

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.

我们不太可能在VS2010版本之前修复这些问题.解决方法是更正OutputPath或从父项继承.

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.

这篇关于如何在Visual Studio 2010中修复错误MSB4018?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆