Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF - error: [xxx] "does not contain a definition for [zzz] and no extension method [zzz] could be found

I get an error while compiling:

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

I got this error while compiling a user control and its owning window in the same project.

Why ?

like image 997
Eric Ouellet Avatar asked Dec 17 '13 19:12

Eric Ouellet


1 Answers

The problem is the naming of the userControl in its owning Window. I named as:

Name="UserCtrlSimulator"

instead of:

x:Name="UserCtrlSimulator"

You can find the bug and a more useful error message by removing the reference of that badly named object (remove any reference to the object named without the "x:").

I can't tell the exact reason why it is like this ??? But my solution works fine.

Hope it can help anybody because I lost a lots of time with this weird bug.

like image 68
Eric Ouellet Avatar answered Oct 26 '22 20:10

Eric Ouellet