VS Issue: Designer failing

October 27, 2013

Update: I believe I solved this issue, and this post has been refined to point to the actual issue (and not the way I treated the symptoms of the bad cache).


I was running into an issue while developing in my Windows Phone app in Visual Studio. After banging my head against the wall for several hours looking for a ‘real problem’, it turned out to be an issue in my view model.

My Issue

For any XAML pages in my project where I used the Telerik controls in my project, I received a design-time error whenever Visual Studio attempted to render the page. Funny enough, the error was different depending on which instance of Visual Studio I opened/ran the project in:

  • Visual Studio 2013: ObjectDisposedException: Cannot access a disposed object (NativeObject)
  • Visual Studio 2012: Error HRESULT E_FAIL has been returned from a call to a COM component

NativeObj Exc

This error drove me nuts for a variety of reasons:

  • The same XAML worked in other projects (e.g., Telerik sample code)
  • Creating a blank/new XAML page worked until I added any of the Telerik controls
  • Reinstalling/readding the Telerik controls didn’t do anything.
  • The stacktrace was absolutely meaningless

Funny enough, the error keeps coming back – and I’m guessing it seems to be related to having the Telerik controls open in two projects at the same time in VS2013. It looks like VS2013 changed the way it handles errors in the XAML files – I say this because the sample data XML file that I was using in VS2012 had no issues, but it reported issues in VS2013.

My Initial Solution – Cleaning the Cache

After playing with a large number of things, I tried doing an aggressive cleaning of everything related to the project:

  1. I did a ‘clean’ for every project in the solution
  2. I removed every \bin and \obj folder in the solution
  3. I cleared out the Visual Studio designer temp files
  4. I cleaned up Windows temporary files

After doing the four things above, I returned back to my project, did one more Clean (just because you always double-tap Smile) and then did a Build on my WP project. I then reopened the XAML file, and everything worked once more! Yay! However, opening it up in VS2013 caused everything to get hosed again. So, I did more digging and eventually found my issue was in how I interacted with Isolated Storage in my view model.

My Solution – Fixing my ViewModel


At the heart of the issue, I was using isolated storage settings in my view model (for storing username and a userhash), which I was then taking advantage of in my sample data xml file. And that sample data XML file was being used to render design time data in XAML via data binding. VS2013 seems to look for and throw an error in the sample data XML that VS2012 wasn’t throwing, and this is what was causing an issue above.

I added the below check around the assignment/reading of the IsolatedStorageSettings object to verify that it should go over to the isolated storage area before actually doing so:

if (!System.ComponentModel.DesignerProperties.IsInDesignTool) {
  settings.TryGetValue<string>("username", out m_username);

Using the above check prior to doing a TryGetValue, everything now works appropriately, treating not just the symptoms, but the root cause.

Hope this helps!

Cliff Simpkins


5 responses to VS Issue: Designer failing

  1. So.in conclusion..what was it!?

  2. I don’t know the actual root of what’s causing it. Given it happens almost every time I open up a project asset containing a Telerik control in VS2013, I’m assuming there’s an issue with the [older] Telerik controls I’m using and VS2013.

    As using VS2012 works just fine, I’ve reverted back to that. 😮

  3. Hi Cliff,

    this issue also exists with the newest versions of the Telerik controls. I’ve been in close contact with the Telerik guys but unfortunately they can not reproduce it. Updating to the latest VS2013 update 1 RC which contains fixes in the XAML designer did not work either. I even tried to debug VS2013 with another instance as described in the MSDN docs but for some reason the ObjectDisposedException is not catched by the debugging instance.

    So for now, VS2013 (just like 2012) is not usable when using the Telerik controls (at least on my side).

    Is there any way to get some logs/traces specifically from the XAML designer? I mean this ObjectDisposedException somehow somewhere should trigger a log event, shouldn’t it?

    Regards, Stephan

    • I believe I actually figured out my issue! 🙂

      My problem had to do with the viewmodel I was databinding the XAML page to. In case it helps, I updated the blog post to have more information about my issue – let me know if it helps!

Trackbacks and Pingbacks:

  1. Windows Store App Developer Links – 2013-10-30 | Dan Rigby - October 29, 2013

    […] VS Issue: Designer failing (Cliff Simpkins) […]