ZitoDozo
ZitoDozo

Reputation: 93

Error CS1061 “...Does Not Contain Definition and No Extension Method...accepting a first argument of type ” could be found

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.

Upvotes: 7

Views: 234373

Answers (4)

Ender Bahar
Ender Bahar

Reputation: 1

I got the same error when I installed SpecFlow package to my .NET project . Uninstalling it fixed the issue

Upvotes: 0

mansour bagheri
mansour bagheri

Reputation: 11

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

Upvotes: 1

حصه
حصه

Reputation: 9

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; }

Upvotes: 0

Davesoft
Davesoft

Reputation: 764

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.

Upvotes: 4

Related Questions