pokoko222
pokoko222

Reputation: 11

are you missing a using directive or an assembly reference

I can't figure out this error in visual c#.

Error   1
'Engine.VerticalMenu' does not contain a definition for '_buttons' and no extension method '_buttons' accepting a first argument of type 'Engine.VerticalMenu' could be found
(are you missing a using directive or an assembly reference?)   

For this line:

System.Diagnostics.Debug.Assert(false, _menu._buttons.Count.ToString());

I have two projects, first one is Engine with same namespace Engine and of type class library, and the other one is windows form app that uses this Engine library. I have both using directives and references to project, what could possibly be causing this? Thank you.

Upvotes: 1

Views: 6360

Answers (5)

Rune FS
Rune FS

Reputation: 21742

Check that all the assemblies referenced by the project Engine is also referenced by your Win form.

It would usually give another error if that's the case but not always. If they are all referenced. Try a rebuild of just the Engine project. VS might throw the mentioned error if there's a compilation error in a referenced project. Those errors should show up in the error log, so you could also check the error log to see if there are other errors some of which is in engine. (Even if that's not the case I would personally still build Engine alone, to completely rule it out)

Upvotes: 0

hcb
hcb

Reputation: 8357

No, its not the public thing, vs has other errormessages for that. It looks like _menu doesn't have a member _buttons at all. So this means either the class or the interface _menu is of doesnt have _buttons.

Upvotes: 0

Chuck Conway
Chuck Conway

Reputation: 16435

It sounds like a naming conflict (namespace or class). Have you tried using the fully qualified name for the class? Without more information this is just a shot in the dark.

Upvotes: 0

Sascha
Sascha

Reputation: 10347

Is _buttons possibly private? Then it is not visible outside of the menu class and you can't access it. Wrap it to a public property and you can access it.

Upvotes: 1

Shadow Wizard
Shadow Wizard

Reputation: 66389

Looks like _buttons is private class member, so you can't access it from the outside.

Either make it public, or even better add public getter to the class of _menu:

public TypeOfButtonCollectionHere Buttons { get { return _buttons; } }

And change the calling code to:

 System.Diagnostics.Debug.Assert(false, _menu.Buttons.Count.ToString());

Upvotes: 1

Related Questions