I have a small WPF application which used to compile just fine but is not anymore. I can\'t really say at which point it stopped building. It just worked fine one day, and t
Just run code analysis from Build menu
I found that running the command "Run Code Analysis" re-builds everything and almost always fixes the problem (right click project > Analyze > Run Code Analysis). This also generally re-builds the resource files also so that strings, etc. can be found.
Here's a weird example of a similar thing:
<UserControl x:Class="Gtl.Ui.Controls.WaitControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:Gtl.Ui.Controls"
mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="120"
Background="Transparent">
...
</UserControl>
will compile (VS2013).
<UserControl x:Class="Gtl.Ui.Controls.WaitControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:Gtl.Ui.Controls"
mc:Ignorable="d"
d:DesignHeight="120" d:DesignWidth="120"
Background="Transparent"
IsVisibleChanged=onIsVisibleChanged>
...
</UserControl>
produces the error "type Ui not found in Gtl.Ui.Gtl" (and I assure you the handler method exists in the code-behind). The work-around is to add the handler in the class constructor, but c'mon Microsoft, wtf is going on?
This error usually occurs when project was not build successfully during the last build.
Step-1) First remove all the error causing code from the XAML or .cs file and build & start the project by pressing F5.
Step-2) Add add your error causing code in XAML one by one.
Tried all solutions on this thread but none worked. It turned out to be cause by the solution configuration. My WPF app was set to build for X64 because of some native dependencies that require it but the solution configuration was still set to AnyCPU for the project. Creating a new X64 configuration for the project in the solution configuration manager allowed the XAML designer to finally recognize my type and namespace.
None of the solutions worked for me. I fixed it this way: