Error creating instance of managed object

I'm getting this error sometimes when creating a new project or when opening an existing one:
Project'ConsoleApplication3'could not be opened because the VisualC# 2012 compiler could not be created. Error creating instance of managed object 'Microsoft.VisualStudio.CSharp.Services.Language.ManagedObjectFactory'
