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

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:
- I did a ‘clean’ for every project in the solution
- I removed every \bin and \obj folder in the solution
- I cleared out the Visual Studio designer temp files
(C:\Users\{user}\AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache) - 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 ) 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