views:

523

answers:

3

Okay so I have a Window in WPF. I add the following line inside of it:

xmlns:controls="clr-namespace:mCubed.Controls"

This compiles and runs just fine, but the Visual Studio designer gives me this error:

Could not load file or assembly 'mCubed, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

When I remove this line from the Window, it compiles and runs just fine and the Visual Studio designer works like a charm!

I'm confused as to why that one line breaks the designer? This occurs REGARDLESS if I have put the following line in the body of the XAML document.

<controls:MyControl/>
A: 

it could be some vs bug, or maybe this namespace is the same as the window namespace???

Chen Kinnrot
The Window which I have a class cleverly named mCubedWindow for is inside an mCubed namespace. I put all my controls in the mCubed.Controls namespace.
Nick
There is no problem having a window under the same namespace as a control it uses.
Danny Varod
+2  A: 

Is MyControl in the same assembly as the window? If it isn't, you need to include the assembly name in the declaration:

xmlns:controls="clr-namespace:mCubed.Controls;assembly=mCubed"
Daniel Pratt
Its in the same Visual Studio project so I guess. It compiles and runs with no problems, so I dont think that's the problem. It shouldn't even compile if that were the case.
Nick
A: 

Is the XAML loose (Build action: None, No code behind) or compiled (Build action: Page, Can have code behind)?

If the XAML is loose or if MyControl is in a different assembly you must specify which assembly MyControl is in, like Daniel Pratt stated:

xmlns:controls="clr-namespace:mCubed.Controls;assembly=mCubed"

Make sure the assembly mCubed and its dependencies (references) are copied to your output directory. If they are not, then add mCubed as a reference to the start-up project.

Danny Varod