Visual Studio 2010在编译C++/CLI项目时出现奇怪错误

Visual Studio 2010 giving odd errors compiling C++/CLI project

本文关键字:错误 项目 CLI 2010 Studio 编译 C++ Visual      更新时间:2023-10-16

当我试图编译VS2010 Windows窗体应用程序时,遇到了一系列奇怪的错误。我得到的错误是:

错误C2871:"project_6":具有此名称的命名空间不存在

错误C2653:"Application":不是类或命名空间名称

错误C3861:"EnableVisualStyles":找不到标识符

错误C2653:"Application":不是类或命名空间名称

错误C3861:"SetCompatibleTextRenderingDefault":找不到标识符

错误C2653:"Application":不是类或命名空间名称

错误C2061:语法错误:标识符"Form1"

错误C3861:"运行":找不到标识符

错误C1854:无法覆盖在对象文件"c:\users\dan\documents\visual studio 2010\projects\project_6\debug\stdafx.obj"中创建预编译头期间形成的信息

所有的编译器错误都将该文件作为我的main.cpp文件,除了最后一个,它给出了stdafx.cpp。下面是我的main.chpp文件(它是VS2010自动生成的文件):

// project_6.cpp : main project file.
#include "stdafx.h"
#include "Form1.h"
using namespace project_6;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
    // Enabling Windows XP visual effects before any controls are created
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false); 
    // Create the main window and run it
    Application::Run(gcnew Form1());
    return 0;
}

无论如何,我已经无计可施了,正试图弄清楚它出了什么问题,希望这里有人能提供一些见解。

我认为您至少需要添加对System.Windows.Forms和System.Windows.Drawing.的引用

相关文章: