在 Visual Studio Express 2010
中,我通常只能构建一个程序一次,然后要进行任何更改,我必须将我的代码粘贴到一个新项目中。它会说构建成功,但随后我尝试运行它并收到一条错误消息:
"This project is out of date-- would you like to build it?"
然后我单击是,我收到另一条错误消息,指出存在构建错误,我必须从上次成功的构建继续。 有时 我没有运行上次成功的构建,而是收到一条错误消息,说,
"Unable to open [directory to program]. The system cannot find the file specified."
出于这个原因,我通常使用 Visual Express 2012
,但即便如此,它时不时地发生,似乎是随机的。一旦问题开始出现,就没有明显的方法来修复它(重建和重新启动 Visual Studio 都会产生相同的结果)。在 Visual Studio Pro 2012
中,这似乎也发生了。
编辑:这是在我前面的输出框中(2010 版)
1>------ Build started: Project: Lab01, Configuration: Debug Win32 ------
1> Lab01.cpp
1>c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\system.core.dll : warning C4945: 'ExtensionAttribute' : cannot import symbol from 'c:\program files (x86)\reference assemblies\microsoft\framework\.netframework\v4.0\system.core.dll': as 'System::Runtime::CompilerServices::ExtensionAttribute' has already been imported from another assembly 'mscorlib'
1> c:\windows\microsoft.net\framework\v4.0.30319\mscorlib.dll : see declaration of 'System::Runtime::CompilerServices::ExtensionAttribute'
1> first seen type is used; re-order imported assemblies to use the current type
1> This diagnostic occurred while importing type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
1>Lab01.cpp(28): error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::get(_Elem &)' : cannot convert parameter 1 from 'char [101]' to 'char &'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
我猜它说那里有错误,但出于某种原因它告诉我“构建成功”...
最佳答案
查找和分析 Visual Studio 报告的错误的方法如下:
从上次成功的构建继续
- 点击NO(几乎总是)。错误应该显示在 View->Error List
中。混淆时,总是在构建后检查 View->Output
窗口,它有很多相同的信息,但更详细。
rebuilding ...same result
- 完全重建应该会给出除project is outdate
之外的一些其他错误。
Lab01.cpp(28):错误 C2664:
- Lab01.cpp 的第 28 行和第 3 行上下会有所帮助。
看起来你在用 std::streams 做一些不正确的事情,但我不知道在没有看到代码的情况下是什么。 这应该在错误列表中
警告 C4945:
- 发生这种情况是因为您在单个项目中混合使用 .net 4.0 和 4.5 以及(可能)混合使用 clr 和非 clr 代码。从已在各处选择了正确的 .Net 库版本的新 CLR 项目重新创建可能会删除此警告。 (ExtensionAttribute
在 4.0 到 4.5 升级期间移动了)
这只是一个警告,所以应该无关紧要。
关于c++ - 是什么导致 MS Visual Studio 无法识别构建错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21023021/