簡體   English   中英

視覺工作室。 無法啟動程序 '' 系統找不到指定的文件

[英]Visual Studio. Unable to start program '' The system cannot find the file specified

它是我在 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'系統找不到指定的文件。”

這是我的第一個程序,我無法運行它。 我相信這可能是由於項目的文件路徑 - 無法找到合適的文件。 我也不知道要調整哪個設置......可能是一個非常簡單的解決方案,但我無法在網上找到它。 謝謝。

根據您的示例代碼,這是一個 C++ 項目而不是 C# 項目。 如果要創建 C# 項目,則需要不同的代碼。

如果您創建了一個 C++ 項目,並收到此錯誤。 我建議您可以按照以下步驟解決問題:

1,您應該在運行之前構建項目。

此錯誤的原因很可能是因為您尚未從Build > Build Solution構建您的項目。 嘗試運行項目時出現此錯誤的原因是 Visual Studio 找不到生成項目時應生成的可執行文件。

2、檢查鏈接器輸出文件是否與目標文件的路徑、名稱和擴展名匹配。

右鍵單擊項目名稱 > 屬性 -> 鏈接器 > 常規 -> 輸出文件 > $(OutDir)$(TargetName)$(TargetExt)

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM