How can I get all classes inside a namespace?
+7
A:
You cannot. Classes are not "in" namespaces. Classes have namespaces as part of their name.
The classes "in" a namespace may reside in multiple assemblies. For example, some of the types in the System
namespace reside in mscorlib.dll, and others reside in System.dll. You would have to go through all of the types in all of the assemblies you could find to be certain that you had found all the types "in" a particular namespace.
John Saunders
2010-07-28 14:03:01
My classes are in App_Code
Andreas
2010-07-28 14:05:06
Is this a web site, created with File->New Web Site? In that case, I think you're completely out of luck. Web Sites don't build into a single assembly - there's one per page (I don't know which assembly the App_Code classes go into). Maybe you'd get lucky and could use Assembly.GetExecutingAssembly to find the current assembly, do GetTypes on that and go through them all.
John Saunders
2010-07-28 14:08:46
A:
Use Reflector to see them (assuming that all the classes are in the same assembly).
David Lynch
2010-07-28 14:03:19
+1
A:
As @hawk mentioned, the answer is located here, with sample code that you can use:
http://stackoverflow.com/questions/79693/getting-all-types-in-a-namespace-via-reflection
code4life
2010-07-28 14:06:06