Clearing corrupted MEF cache in Visual Studio 2017 (and solving the IScriptExecutor error)

Posted: (EET/GMT+2)

 

If Visual Studio 2017 starts throwing "IScriptExecutor" or other odd composition errors during startup, it might be due to a corrupted MEF (Managed Extensibility Framework) cache.

You can safely delete the cache; Visual Studio will rebuild it on the next launch. It might take even a few minutes if you have lots of components and/or extensions installed, but usually solved this kind of errors effectively.

To clear the MEF cache, first close Visual Studio. Then, delete these folders:

%LocalAppData%\Microsoft\VisualStudio\15.0_xxxxx\ComponentModelCache
%LocalAppData%\Microsoft\VisualStudio\15.0_xxxxx\MEFCacheBackup

Be sure to replace the "xxxxx" with your instance ID. The VSWhere utility can be useful here.

Once you have deleted these folders, restart Visual Studio. It will start to recreate the cache, which most of the time clears the "IScriptExecutor" and other initialization errors.

This problem can also happen when updating certain extension. Again, clearing the MEF cache remains the first fix to try when Visual Studio starts acting up after an upgrade.