WPF: VS2012 designer shows "The component 'XXX' does not have a resource identified by the URI YYY"

tete picture tete · Jul 11, 2013 · Viewed 7.7k times · Source

As the title suggests, this error is thrown by the designer, which means the designer can't display my UserControl correctly which in turn means I can't navigate smoothly from element to element in this UserControl to make modification. Really annoying.

XXX is the name of my UserControl, while the URI YYY is actually XXX's path. So I don't know understand it can't find itself as resource. I googled this error, but most of them happened in the runtime. In my case it doesn't happen at all when I execute it. The description of this error is really not explanatory enough, because I am not sure who in the CLR is loading the file itself as a resource.

Another thing might be worth mentioning is, this error only happens after I build my application project, which the error UserControl resides in. After I click to clean the project, the designer can display the whole stuff (but obviously I can't clean the project every time before I make any change, since the building takes time)

Answer

o_weisman picture o_weisman · Oct 22, 2013

It is possible that the control's .g.cs or .g.i.cs file has been corrupted. Try to clean, close visual studio and restart it. I think that helped for me in several cases especially when I copy paste controls from one solution to another.