7

I am new to .NET visual studio, building windows Form Application.

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.

'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?)

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. 1>------ Build started: Project: Engine, Configuration: Release Any CPU ------

  2. 1> Engine -> C:\Users\Admin\Documents\Visual Studio
    2013\Projects\SuperAdventure\Engine\bin\Release\Engine.dll

  3. 2>------ Build started: Project: SuperAdventure, Configuration: Release Any
    CPU ------

  4. 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 ==========

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.

ZitoDozo
  • 93
  • 1
  • 1
  • 5
  • 1
    Hi, welcome to stackoverflow. Can you provide the code you were using that caused this issue? Looks like something is trying to reference `label5_Click` somewhere. In Visual Studio you can use `Ctrl+Shift+F` to find all references of a string in your solution. – JamesFaix Jul 03 '18 at 15:28
  • 2
    It seems you accidently clicked on the label in the designer window and the designer added an event handler (`label5_Click`). Then you deleted that handler from your code file but forgot to delete this assignment in the designer.cs file. – René Vogt Jul 03 '18 at 15:32
  • 1
    This should be tagged WinForms not asp.net. I started programming by wanting to write a game also, which caused me to buy a plethora of books and grind hard only to find out years later that I started out WAY over my head. So don't shy from it but if you're open to some advice you have a long long long way to go. I would go ahead and take the first leap into hours of videos and books that will save you alot of time and struggle before going much further. – Michael Puckett II Jul 03 '18 at 16:47

3 Answers3

3

Quick solution: Delete this.lblExperience and create it again.

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.

Other quick solution: Delete that line. But then you have no handler for its click event, which may be intentional.

Tanktalus
  • 21,664
  • 5
  • 41
  • 68
Davesoft
  • 724
  • 1
  • 4
  • 10
1

when you made the database with CodeFirst or use Identity for Register Users and you add your class to IdentityModes you can use from IDbSet and DbSet if you over the IDbSet press the F12 you see that its does not access to async methods like FindAsync but when you use from DbSet this method access to async methods and you can see it if you press F12 over the DbSet when asp mvc make the controller and wives by it self and you use async mode you have some Errors by this text Error CS1061 “…Does Not Contain Definition and No Extension Method…accepting a first argument of type ” could be found

you must go to the DbContext class and change IDbSet<> to DbSect<> and this error went and your project successfully run thanks for your time

0

For me, I opened IdentityModel class and I modified the System.Data.Entity, the final result:

public System.Data.Entity.DbSet<EventSystem.Models.Admin> Admins { get; set; }
Shayki Abramczyk
  • 36,824
  • 16
  • 89
  • 114
حصه
  • 1
  • 1
  • 2