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: 
Based on [Frank59's](https://stackoverflow.com/a/13766250/177710) answer but a bit more concise:

```
var appDomain = AppDomain.CurrentDomain;
var flags = BindingFlags.NonPublic | BindingFlags.Instance;
var fieldInfo = appDomain.GetType().GetField("_LocalStore", flags);
if (fieldInfo == null)
    return;
var localStore = fieldInfo.GetValue(appDomain) as Dictionary<string, object[]>;
if (localStore == null)
    return;
foreach (var key in localStore.Keys)
{
    var nonNullValues = localStore[key].Where(v => v != null);
    Console.WriteLine(key + ": " + string.Join(", ", nonNullValues));
}

```
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

```