C# Get All Dynamic Types in a Given AppDomain


One of the bigger projects that I am working on at work has me loading dynamically generated assemblies into a separate app domain and making calls to those assemblies.

The reasons one would want to do this are varied, and the mechanics of making it actually happen are well beyond the scope of this little blurb. But I recently ran across a need to know all the types that were loaded into this other app domain, and I couldn’t find exactly what I needed online anywhere so I decided to make a note of it here in case I ever needed it again.

var types = (from a in myAppDomain.GetAssemblies()
                         where a.IsDynamic
                         from t in a.GetTypes()
                         select t).ToList();

Leave a Reply

Your email address will not be published. Required fields are marked *