Question: In order to store the state of processes when an error occured, I would like to list all (custom) data stored in AppDomain (by SetData).
The LocalStore property is private and AppDomain class not inheritable.
Is there any way to enumerate those data ?

Answer: 
```
        AppDomain domain = AppDomain.CurrentDomain;
        domain.SetData("testKey", "testValue");

        FieldInfo[] fieldInfoArr = domain.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
        foreach (FieldInfo fieldInfo in fieldInfoArr)
        {

            if (string.Compare(fieldInfo.Name, "_LocalStore", true) != 0)
                continue;
            Object value = fieldInfo.GetValue(domain);
            if (!(value is Dictionary<string,object[]>))
                return;
            Dictionary<string, object[]> localStore = (Dictionary<string, object[]>)value;
            foreach (var item in localStore)
            {
                Object[] values = (Object[])item.Value;
                foreach (var val in values)
                {
                    if (val == null)
                        continue;
                    Console.WriteLine(item.Key + " " + val.ToString());
                }
            }

        }

```
Same solution, but as an F# extension method. May not need the null check.
<https://gist.github.com/ctaggart/30555d3faf94b4d0ff98>

```
type AppDomain with
    member x.LocalStore
        with get() =
            let f = x.GetType().GetField("_LocalStore", BindingFlags.NonPublic ||| BindingFlags.Instance)
            if f = null then Dictionary<string, obj[]>()
            else f.GetValue x :?> Dictionary<string, obj[]>

let printAppDomainObjectCache() =
    for KeyValue(k,v) in AppDomain.CurrentDomain.LocalStore do
        printfn "%s" k

```