How Visual Studio’s Component Model Cache can be a pain.

VisualStudio.withMartin

The Problem

Once in a while when I’m working with Visual Studio, 2013 in my case, it craps our on my and starts doing weird stuff, hardly a scientific term, but I have no other words for it. Just, at random, I have no clue why or how this happens, it just happens. It not only happens to me, but also to my colleagues once in a while, so I know I’m not the only one, which means that, if you are reading this, there is a large chance you are having one of the following issues.

When starting Visual Studio …

  • … by loading a solution file, no windows display and the Solution Explorer remains empty.
  • … you get a bunch of error messages thrown in your face.
  • … you can only add text in the editor, not remove it.
  • … some other strange, unexplainable thing prevents you from using Visual Studio as you normally would.

The Solution

If you are having one of the issues above and neither restarting Visual Studio or rebooting your machine helps, then there is a large change your Component Model Cache is corrupt. I don’t know the details of what exactly it is or does, and frankly, I don’t care, I just want my IDE to work as it should work. One noteworthy point though, I use the ReSharper for C# plugin extensively, I don’t know if that has anything to do with it, but I thought I’d mention it just for the record.

So, here is how you fix it:

  1. Close Visual Studio (if you haven’t done so already out of despair)
  2. Open a file explorer window and navigate toyour AppData folder. You can get there by:
    1. In the search bar, type %APPDATA%/.. and press enter
    2. Alternatively, navigate to C:\Users\\AppData
  3. Go into Local\Microsoft\VisualStudio\<version> where <version> is 12.0 for Visual Studio 2013.
  4. Delete the ComponentModelCache folder.

When you start Visual Studio now, everything is back to normal. It will automatically regenerate the files it needs in the Component Model Cache, so don’t worry about deleting any crucial data.

I hope this is useful to someone out there, it certainly saved me a real headache when I first encountered the problems.

-Martin

  • S.A. Khalili

    It didn’t helped me, my problem is after an update on Visual Studio 2015 I got few hundreds of errors saying misssing assembly or inaccessible due to protection level.

    • Maarten Thomassen

      It is possible your problem is something else, sounds like you might need to reinstall Visual Studio completely. Could you let us know your solution when you found it?

      • S.A. Khalili

        Sorry for late reply,I waited in hope that I might find a solution but the problem is not fully resolved yet, some how I managed to work on some of my projects which were needed.

        I reinstalled Visula Studio but not changes, the Solution/Project I work on consist of tens of projects which some are datedback to 5 year +, I Cleaned and Rebuilt each project one by one and tried to read the error messages and in many cases one project was linked to other so needed to rebuild the linked project first, some times needed to add missing dlls like Aforge from NuGet. Some projects were not compitable with the latest Visulal Studio so i Unloaded them because I don’t need them at the moment.

  • m asad

    Still shown this error

  • Ashish Korat

    Fixed the issue by deleting ComponentModelCache folder. Thanks