SharePoint: Where have my content types gone?

Have all your SharePoint site columns and content types ever mysteriously vanished from your site collection?  What could cause this catastrophe to occur?

At one time or another when you are developing solutions for SharePoint (MOSS 2007/WSS 3.0) you will be creating and deleting site collections regularly in order to test a piece of functionality.  It is quite possible that you have done this before so you’ll know what I am talking about.

One thing that might scare you a little is if you click on Site Settings > Site Content Types and you’re faced with a huge range of options. By this point panic has set in and you are surely either running around the room like a headless chicken or else you have put your coat on and are heading for the nearest high street coffee emporium.

Where are my Content Types?

You will notice that the same is true of your Site Columns too!   Wait, come back. Take off that coat, you can get a coffee in a minute.

The solution is simple and could easily be solved with one simple thing.  Time.  The Site Content Type Gallery and the Site Column Gallery are both cached on the WFE and this is only updated via a timer job.  Because you have just deleted and recreated a site collection on the exact same URL as a previously existing one this timer job has not yet run to re-populate this cache.  I think this is the ConfigRefresh job, but I am not certain.

If you want to be sure then you can run the following command on your server(s) and you will see that all the site columns and content types will come straight back:

iisreset -noforce

Of course if you just wait then the timer job will run and all will be well.

This one has caught me out before, so hopefully this will help someone out and stop them running for coffee instead of doing a simple iisreset.