视觉工作室。无法启动程序''系统找不到指定的文件

时间:2019-12-27 03:28:45

标签: c++ visual-studio

这是我在C#上的Visual Studio上的第一个程序。 我没有编写自己的代码,我试图通过简单的控制台写入来打开任何模板项目。

// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>

int main()
{
    std::cout << "Hello World!\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


但是我收到我不知道如何解决的错误。

错误: 无法正确构建。 当我尝试构建时,会有很多错误 例如 无法打开源文件...(大量信息) 全球范围没有....(大量)
当我尝试运行时,显然它不会运行。它会告诉我 “无法启动程序。'C:\ repo .... \ Debug \ ConsoleApplication1.exe'系统找不到指定的文件。”

这是我的第一个程序,我无法运行它。我相信它可能是由于项目的文件路径-无法找到适当的文件。我也不知道该调整哪个设置……可能是一个非常简单的解决方案,但我无法在线找到它。谢谢。

1 个答案:

答案 0 :(得分:0)

根据您的示例代码,这是一个C ++项目,而不是C#项目。如果要创建C#项目,则需要其他代码。

如果您创建了一个c ++项目,并收到此错误。我建议您可以按照以下步骤解决问题:

1,您应该在运行项目之前对其进行构建。

此错误的原因很可能是因为您尚未通过 Build> Build Solution 来构建项目。尝试运行项目时出现此错误的原因是,Visual Studio找不到在构建项目时应生成的可执行文件。

2,检查链接器输出文件是否与目标文件的路径,名称和扩展名匹配。

右键单击项目名称>属性->链接器>常规->输出文件> $(OutDir)$(TargetName)$(TargetExt)

enter image description here