سؤال

Is there a way to return only the types in a loaded assembly and not have it look for the nested ones so that the error TypeLoadException does not occur?

foreach (var type in _assembly.GetTypes().Where(type => type.IsClass))

هل كانت مفيدة؟

المحلول

IsNested property of System.Type might help you to filter those out.

You could also use Mono.Cecil to browse the assemblies if you do not need to load them.

Cecil is a library written by Jb Evain (http://evain.net/blog/) to generate and inspect programs and libraries in the ECMA CIL format. It has full support for generics, and support some debugging symbol format.

In simple English, with Cecil, you can load existing managed assemblies, browse all the contained types, modify them on the fly and save back to the disk the modified assembly.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top