CSharp examples for System.Reflection:Assembly
Get Accessible Types from Assembly
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. using System.Reflection; using System.Linq; using System.Collections.Generic; using System;//w w w. j a va 2s. com public class Main{ public static IEnumerable<Type> GetAccessibleTypes(this Assembly assembly) { try { return assembly.DefinedTypes.Select(t => t.AsType()); } catch (ReflectionTypeLoadException ex) { // The exception is thrown if some types cannot be loaded in partial trust. // For our purposes we just want to get the types that are loaded, which are // provided in the Types property of the exception. return ex.Types.Where(t => t != null); } } }