When running IContentLoader.TryGet(ContentReference contentReference, ILanguageSelector languageSelector, out T Content), if the content reference's content type was defined by code that no longer exits, then an EPiServerException is thrown with the following message:
"Could not create instance of content type "PartsCartContent" since it has an invalid .NET class associated: XXXXX.PartsCartContent, XXXXX.Shop, Version=188.8.131.52, Culture=neutral, PublicKeyToken=null"
This happens for custom content type named "PartsCartContent" that inherited from EPiServer.Core.ContentBase (i.e. it's neither a page nor a block) before being deleted.
Instead of throwing an Exception I'd suggest that IContentLoader.TryGet(...) returns false if the above error occurs.
I'm using EPiServer CMS 9.12.2.