Windows窗体应用程序 - 项目构建但设计器无法识别List <t> </t>

时间:2013-08-22 20:23:11

标签: c++ winforms list

我正在开发Visual C ++ 2010中的Windows窗体应用程序。 我正在尝试使用List(System :: Collections :: Generic :: List)。直到某一点,一切都很好。然后,由于没有特别的原因我可以看到,设计师开始没有将Link ^识别为一种类型。错误消息是:

C ++ CodeDOM解析器错误:行:70,列:17 ---未知类型'System.Collections.Generic.List ^'。请确保引用包含此类型的程序集。如果这样type是开发项目的一部分,请确保项目已成功构建。

奇怪的是项目构建和运行完美,唯一导致问题的是Designer。

以下是重要的(据我所知)代码部分:

using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
using namespace System::Collections::Generic; //I only added this line

private: System::Collections::Generic::List<String^>^ MyText;
//Manually added the line above
private: System::Windows::Forms::Button^  button1;

void InitializeComponent(void)
{    
    this->MyText = (gcnew System::Collections::Generic::List<String^>());
    //again, added the line above
    this->button1 = (gcnew System::Windows::Forms::Button());
}

//and this is how I'm currently using the List
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
{
    textBox1->Text = MyText->Count + " " + MyText->Capacity;
}
// textBox1->Text becomes 0 0

我已经尝试了System :: Collections :: Generic :: List ^ MyText和List ^ MyText,(因为我添加使用命名空间System :: Collections :: Generic )但它仍然给我错误信息。

我已经在其上注释了带有List的代码,并且设计器工作得很好,但是当我将代码重新放回播放时,错误又回来了。我尝试无休止地重启Visual C ++,从项目中删除文件并再次添加,结果总是一样的:项目构建,设计器不起作用。我是出于想法,所以...任何帮助?

(哦,还有一个选项可以跳过错误,它确实向我展示了设计师,大多数情况下,但是,当程序在您点击该选项时发出警告时,有时会显示缺少一些控件的设计器和代码块从Form1.h中消失

0 个答案:

没有答案