The above solution made me grin as it helped me solved my serialization puzzle. However, if you have an extensible format with components spread over multiple assemblies, this solution may not pick up all the types.
I brute force it as follows:
List<type> knownTypes = new List<type>();
foreach (var a in AppDomain.CurrentDomain.GetAssemblies())
{
knownTypes.AddRange(Assembly.GetExecutingAssembly().GetTypes().Where(
t => typeof(XMLBinaryPackageInfo).IsAssignableFrom(t)));
}
My rationale is that this code is unlikely to be called often enough to worry about enumerating such a potentially vast number of types. I don't cache this stuff but you can keep track of assembly loading / unloading if you must. Mileage may vary!