问题描述
.NET Visual Studio是我的新手,正在构建Windows窗体应用程序.
I am new to .NET visual studio, building windows Form Application.
尝试构建解决方案时,出现以下错误.我不确定是否与文件'SuperAdventure.SuperAdventure'或未指定的控件有关.
I had the following error described below, when trying to build a solution. I am not sure if it has to do with something related to the file 'SuperAdventure.SuperAdventure' or a control that was not specified.
这是错误代码,该错误代码在标记行的代码下显示红色的波浪状/线条.
This is the error code with the error showing a red squiggly/line under the code in the marked line.
// lblExperience
//
this.lblExperience.AutoSize = true;
this.lblExperience.Location = new System.Drawing.Point(110, 73);
this.lblExperience.Name = "lblExperience";
this.lblExperience.Size = new System.Drawing.Size(35, 13);
this.lblExperience.TabIndex = 6;
this.lblExperience.Text = "label7";
this.lblExperience.Click += new System.EventHandler(this.label5_Click); // <-- squiggly line here
并在输出上给出以下内容:
and on the output it gives this:
-
1> ------构建已开始:项目:引擎,配置:发布任何CPU ------
1>------ Build started: Project: Engine, Configuration: Release Any CPU ------
1>引擎-> C:\ Users \ Admin \ Documents \ Visual Studio
2013 \ Projects \ SuperAdventure \ Engine \ bin \ Release \ Engine.dll
1> Engine -> C:\Users\Admin\Documents\Visual Studio
2013\Projects\SuperAdventure\Engine\bin\Release\Engine.dll
2> ------开始构建:项目:SuperAdventure,配置:发布Any
CPU ------
2>------ Build started: Project: SuperAdventure, Configuration: Release Any
CPU ------
2> c:\ Users \ Admin \ Documents \ Visual Studio
2013 \ Projects \ SuperAdventure.Designer.cs(119,70,119,82):错误
CS1061:"SuperAdventure.SuperAdventure"不包含"label5_Click"的定义,没有扩展方法'label5_Click'接受类型的第一个参数可以找到"SuperAdventure.SuperAdventure"(您是否缺少使用指令还是程序集引用?)==========构建:1成功,1个失败,0个最新,0个已跳过==========
2>c:\Users\Admin\Documents\Visual Studio
2013\Projects\SuperAdventure.Designer.cs(119,70,119,82): error
CS1061: 'SuperAdventure.SuperAdventure' does not contain a definition for 'label5_Click' and no extension method 'label5_Click' accepting a first argument of type 'SuperAdventure.SuperAdventure' could be found (are you missing a using directive or an assembly reference?) ========== Build: 1 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
如果需要提供更多信息,请告诉我.PS:我是一个初学者,试图通过构建RPG游戏作为练习来学习一些C#.
Please let me know if I need to provided any more information. PS: I am a beginner trying to learn some C# by building a RPG game as an exercise.
推荐答案
快速解决方案:删除this.lblExperience并重新创建.
Quick solution: Delete this.lblExperience and create it again.
该控件似乎找不到其click事件处理程序,并且在不变得太复杂的情况下,先删除该控件,然后双击该控件将创建一个新的处理程序并正确绑定它.
The control can't seem to find its click event handler, and without getting too complex, deleting the control then double-clicking on it will create a fresh handler and correctly bind it.
其他快速解决方案:删除该行.但是然后您就没有针对其click事件的处理程序了,这可能是有意的.
Other quick solution: Delete that line. But then you have no handler for its click event, which may be intentional.
这篇关于错误CS1061"...不包含定义且没有扩展方法...接受类型为“的第一个参数"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!