Visual studio 2012 XAML designer invalid markup

14,175

Solution 1

There's also an issue with the ShadowCache (used for rendering designer) getting out of sync with your XAML in VS2012. I just found this out, as I was having a horrible time with the following error with derived user controls:

The local property XXXX can only be applied to types that are derived from YYYYY.

The shadow cache is located in your user profile directory:

app data\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache

You can delete everything in there and restart VS2012. After that, things worked much better (for at least a while!)

Solution 2

Delete everything in ShadowCache

C:\Users\username\AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache\

Copy-pasteable paths

Just copy/paste one of these paths into Windows Explorer. %LOCALAPPDATA% is a Windows Environment Variable it will be replaced with the corresponding value when entered into Explorer (also works in Command Prompt)

VS2012

%LOCALAPPDATA%\Microsoft\VisualStudio\11.0\Designer\ShadowCache\

VS2013

%LOCALAPPDATA%\Microsoft\VisualStudio\12.0\Designer\ShadowCache\

VS2015

%LOCALAPPDATA%\Microsoft\VisualStudio\14.0\Designer\ShadowCache\

ASP.NET

If you develop ASP.NET also delete

%LOCALAPPDATA%\Microsoft\WebsiteCache

%LOCALAPPDATA%\Temp\VWDWebCache

Solution 3

I'm not sure this will fix all cases but this is what worked for me (all the time now).

I have VS2012, using the Blend designer in the IDE, building an x64 application, when I would define a new ICommand and add the Command attribute, I would get the designer isn't supported in x64 error (I forget the exact warning). If I switch to x86, I'd get invalid XAML markup errors complaining the the ICommand wasn't recognized or was not accessible, no matter how many times I rebuilt in x64. If I switch to x86, build, then switch back to x64, voila, not problems with the designer.

Now I recall similar issues with VS2008 and Blend version 3 and 4. From what I've read in other posts, using Any CPU might also resolve the issue.

Solution 4

You need to re:encode your xaml, open bugged files in ide -> save as -> save encoded (choose UTF8)

Solution 5

In Visual Studio 2013 this is a workaround I using for my Windows Phone Project, http://danielhindrikes.se/visual-studio/workaround-for-invalid-markup-problems-when-developing-for-windows-phone/. I guess it is the same designer that is used when you writing XAML for WPF.

Have tried to delete Shadow Cache but itjust work first time I start Visual Studio, above workaround is the only thing that helped me.

Share:
14,175
moreyummystuff
Author by

moreyummystuff

Updated on June 27, 2022

Comments

  • moreyummystuff
    moreyummystuff almost 2 years

    I've got a project that contains usercontrols. For some reason, the design view for the window which uses the said controls has stopped functioning and insists on "Invalid Markup" - the error given is that some members of the usercontrols are not recognized or not accessible. The project however compiles and executes just fine. Loading it up in VS2010, the editor works fine, no errors whatsoever - the same even in Expression Blend.

    So far I have tried the typical clean, rebuild, manually deleting stuff from obj, updating the .xaml and rebuilding, tried starting VS2012 with /resetuserdata and /resetsettings - the problem persists. I even rolled back to a much older revision of my project, back when the designer was working just fine, no dice - same error. I also tried launching VS2012 as a new windows user to avoid any stored appdata that might be lingering, again a no go.

    Is there some other sort of cache or something that I could manually delete?

    • Davut Gürbüz
      Davut Gürbüz over 11 years
      Do you recently update silverlight. In control panel check all versions are the same for Silverlight,Silverlight Developer, Silverlight Toolkit.With SL5 there are incompatibility problems occurs. Hope helps!
    • moreyummystuff
      moreyummystuff over 11 years
      No I haven't had any silverlight-related changes occurring. I've traced it down to custom properties in usercontrols - something with them confuses the designer in VS2012, but I can't figure out what so far.
    • Davut Gürbüz
      Davut Gürbüz over 11 years
      Ohh sorry I didn't notice VS2012.I have no idea.
    • JMK
      JMK over 11 years
      You ever figure this out? I'm having the same issue!
  • Bas
    Bas over 10 years
    I've had the same issue where the designer would insist that my DataTemplate resources were invalid xaml in a Windows Phone page. I tried everything, but clearing the ShadowCache finally did the trick. This is going to save me so much time and frustration. Thank you so much! Not sure if this has any side effects, but it would be great if you could tell Visual Studio to clear the ShadowCache when it shuts down.
  • H2ONaCl
    H2ONaCl over 9 years
    In VS 2013 Express, I see the error "The Design view cannot display correctly because some custom elements have not yet been built." and errors related to ObjectDataProvider XAML elements necessary to bind enum types to combo boxes or list boxes, when the target is X64. Switching to "Any CPU" allows the designer to work. Then I switch back to X64 and Build works without a designer error.
  • C.J.
    C.J. over 9 years
    "Better way to open that folder"... where do you specify that path. Your answers left me more confused than enlightened.
  • pr0gg3r
    pr0gg3r over 9 years
    Really?!... Press Windows key plus E to open the computer folder (formerly known as My Computer). Click into the navigation bar and paste that uri there. %LOCALAPPDATA% will be replaced by the right folder names - username, operating system and operation language will be automatic taken into account.
  • dotNET
    dotNET over 7 years
    For people directly scrolling to the highest voted answer, see Gooey Developer's answer below. Changing the target platform from x64 to Any CPU worked for me.