vs2008向导生成的CLR工程编译无法通过的解决方法
2009-05-08 10:04
525 查看
vs2008向导生成的CLR工程编译无法通过的解决方法
在vs2008中,使用VC++生成CLR工程之后,在窗体上随便添加一个控件(可显示的,比如文本框、静态框等),然后不做任何修改直接编译,但是编译不过。
在我的工程中,添加了两个控件,一个button,一个checkbox,InitializeComponent()中的相关代码如下:
编译会有以下错误输出:
这个错误表明,Point和Size都不是System::Drawing的成员,手动在System::Drawing的后面添加“::”,结果的确只是出现了Design成员,没有其它任何成员,有点奇怪,然后上网上找,在msdn的论坛中找到了解决方法:
打开工程属性框,然后在Common Properties -> Framework and References中,在右侧的References添加新的引用,即从Add New Reference...弹出的对话框中,在.Net选项卡中选择System.Drawing,然后点确定添加进来即可。但是再编译时,又出现问题:
然后还是在刚才的贴子中,说明了问题所在,直接在InitializeComponent()中把对应行的gcnew去掉即可,修改后如下:
再次编译,通过!
msdn的贴子网址:http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvc/thread/3fe34263-2766-47a5-a8eb-f7581fcbef91/
如果网址无法打开,则在msdn中搜索字符串“'Point' : is not a member of 'System::Drawing'”,这个贴子的名称是:Still having trouble with custom controls
在vs2008中,使用VC++生成CLR工程之后,在窗体上随便添加一个控件(可显示的,比如文本框、静态框等),然后不做任何修改直接编译,但是编译不过。
在我的工程中,添加了两个控件,一个button,一个checkbox,InitializeComponent()中的相关代码如下:
void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->checkBox1 = (gcnew System::Windows::Forms::CheckBox()); // // button1 // this->button1->Location = (gcnew System::Drawing::Point(0, 0)); this->button1->Name = L"button1"; this->button1->Size = (gcnew System::Drawing::Size(75, 23)); this->button1->TabIndex = 0; this->button1->Text = L"button1"; this->button1->UseVisualStyleBackColor = true; // // checkBox1 // this->checkBox1->AutoSize = true; this->checkBox1->Location = (gcnew System::Drawing::Point(0, 0)); this->checkBox1->Name = L"checkBox1"; this->checkBox1->Size = (gcnew System::Drawing::Size(104, 24)); this->checkBox1->TabIndex = 0; this->checkBox1->Text = L"checkBox1"; this->checkBox1->UseVisualStyleBackColor = true; ... ... } |
1>f:/exp/vs2008/project1/goWinService.h(79) : error C2039: 'Point' : is not a member of 'System::Drawing' 1>f:/exp/vs2008/project1/goWinService.h(79) : error C2061: syntax error : identifier 'Point' 1>f:/exp/vs2008/project1/goWinService.h(79) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(79) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(81) : error C2039: 'Size' : is not a member of 'System::Drawing' 1>f:/exp/vs2008/project1/goWinService.h(81) : error C2061: syntax error : identifier 'Size' 1>f:/exp/vs2008/project1/goWinService.h(81) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(81) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(89) : error C2039: 'Point' : is not a member of 'System::Drawing' 1>f:/exp/vs2008/project1/goWinService.h(89) : error C2061: syntax error : identifier 'Point' 1>f:/exp/vs2008/project1/goWinService.h(89) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(89) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(91) : error C2039: 'Size' : is not a member of 'System::Drawing' 1>f:/exp/vs2008/project1/goWinService.h(91) : error C2061: syntax error : identifier 'Size' 1>f:/exp/vs2008/project1/goWinService.h(91) : error C2143: syntax error : missing ';' before ')' 1>f:/exp/vs2008/project1/goWinService.h(91) : error C2143: syntax error : missing ';' before ')' |
打开工程属性框,然后在Common Properties -> Framework and References中,在右侧的References添加新的引用,即从Add New Reference...弹出的对话框中,在.Net选项卡中选择System.Drawing,然后点确定添加进来即可。但是再编译时,又出现问题:
1>f:/exp/vs2008/project1/goWinService.h(79) : error C2664: 'System::Windows::Forms::Control::Location::set' : cannot convert parameter 1 from 'System::Drawing::Point ^' to 'System::Drawing::Point' 1> No user-defined-conversion operator available, or 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>f:/exp/vs2008/project1/goWinService.h(81) : error C2664: 'System::Windows::Forms::Control::Size::set' : cannot convert parameter 1 from 'System::Drawing::Size ^' to 'System::Drawing::Size' 1> No user-defined-conversion operator available, or 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>f:/exp/vs2008/project1/goWinService.h(89) : error C2664: 'System::Windows::Forms::Control::Location::set' : cannot convert parameter 1 from 'System::Drawing::Point ^' to 'System::Drawing::Point' 1> No user-defined-conversion operator available, or 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called 1>f:/exp/vs2008/project1/goWinService.h(91) : error C2664: 'System::Windows::Forms::Control::Size::set' : cannot convert parameter 1 from 'System::Drawing::Size ^' to 'System::Drawing::Size' 1> No user-defined-conversion operator available, or 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called |
void InitializeComponent(void) { this->button1 = (gcnew System::Windows::Forms::Button()); this->checkBox1 = (gcnew System::Windows::Forms::CheckBox()); // // button1 // this->button1->Location = (System::Drawing::Point(0, 0)); // 去掉了gcnew this->button1->Name = L"button1"; this->button1->Size = (System::Drawing::Size(75, 23)); // 去掉了gcnew this->button1->TabIndex = 0; this->button1->Text = L"button1"; this->button1->UseVisualStyleBackColor = true; // // checkBox1 // this->checkBox1->AutoSize = true; this->checkBox1->Location = (System::Drawing::Point(0, 0)); // 去掉了gcnew this->checkBox1->Name = L"checkBox1"; this->checkBox1->Size = (System::Drawing::Size(104, 24)); // 去掉了gcnew this->checkBox1->TabIndex = 0; this->checkBox1->Text = L"checkBox1"; this->checkBox1->UseVisualStyleBackColor = true; ... ... } |
msdn的贴子网址:http://social.msdn.microsoft.com/Forums/en-US/Vsexpressvc/thread/3fe34263-2766-47a5-a8eb-f7581fcbef91/
如果网址无法打开,则在msdn中搜索字符串“'Point' : is not a member of 'System::Drawing'”,这个贴子的名称是:Still having trouble with custom controls
相关文章推荐
- quick-cocos2dx使用windows下向导生成的IOS工程在MAC下编译报错的解决方法
- vs2012下mfc程序通过ado方式使用access数据库编译的程序在xp底下无法使用解决方法
- 【解决】SOUI向导生成项目(VC2013以上版本编译时)无法运行XP解决
- 解决:Android编译源码根目录下/system/vold后,通过push命令将编译生成的vold文件push至system/bin下无法正常开机
- 一个VC6的工程转换为VS2008的工程后,编译找不到而且不能升级vc90.pdb文件的问题解决方法 2010-9-28 14:00
- Android ADT无法编译生成R.java的问题解决方法
- VS2008 编译错误: 生成 cmd.exe 时出错 解决方法
- VS2008中安装ASP.NET MVC2后无法新建工程的解决方法
- SOE for .Net中重新编译生成新的.soe后无法识别的解决方法
- 在AMD机器上使用QT5.8 MSVC2015 32bit无法编译通过的解决方法
- VS2008中安装ASP.NET MVC2后无法新建工程的解决方法
- 解决第三方类库无法通过armv7s编译的方法
- 【Cocos2d-X(1.x 2.x) 修复篇】iOS6 中 libcurl.a 无法通过armv7s编译以及iOS6中无法正常游戏横屏的解决方法
- VS2008资源视图打不开,编译提示 error PRJ0003 : 生成“mt.exe”出错rc.dll,rcdll.dll,mt.dll等问题的解决方法
- 【Cocos2d-X(1.x 2.x) 修复篇】iOS6 中 libcurl.a 无法通过armv7s编译以及iOS6中无法正常游戏横屏的解决方法
- 【Cocos2d-X(1.x 2.x) 】iOS6与iphone5适相关设置随笔(解决第三方类库无法通过armv7s编译的方法、添加Default-568h@2x.png)
- ios 解决第三方类库无法通过armv7s编译的方法
- 解决第三方类库无法通过armv7s编译的方法、添加Default-568h@2x.png
- VS2008 编译错误: 生成 cmd.exe 时出错 解决方法
- vs 2008的工程编译的manifest文件导致程序无法运行,通过设置 /MANIFESTDEPENDENCY (Specify Manifest Dependencies) 解决