I recently needed to cast an object from the Enterprise Library Caching block back to a type, but start getting the popular System.NullReferenceException error in my tests if the value returned from the caching block was null.
The problem is that you cannot cast null back to a non-nullable type like an int.
The answer was to use default(T) this will return null or the default value for the type.
public T Get(string cacheKey)
{
return (T) (_manager.GetData(cacheKey) ?? default(T));
}