Caching XmlSerializer in AppDomain To work around the XmlSerializer memory leak thing I created this:

public static class XmlSerializerCache
{
    public static XmlSerializer GetXmlSerializer(Type type, XmlRootAttribute xmlRoot)
    {
        var cache = System.AppDomain.CurrentDomain;
        var key = String.Format(CultureInfo.InvariantCulture, "CachedXmlSerializer:{0}:{1}", type, xmlRoot.ElementName);

        var serializer = cache.GetData(key) as XmlSerializer;
        if (serializer == null)
        {
            serializer = new XmlSerializer(type, xmlRoot);
            cache.SetData(key, serializer);
        }
        return serializer;
    }
}


As far as I understood, the generated assemblies get unloaded as soon as the AppDomain gets unloaded. So I thought I can use the AppDomain Cache to cache my serializers. 

Is this approach a good one? Or at least a "Leak-Safe" one?
According the work around section in the kb article mentioned in the blog entry, your solution looks correct.