c# - How to get all namespace in project by assembly? -


this question has answer here:

i want namespace in main project method assembly.(not aseembly)

i read below question not useful.

getting types in namespace via reflection

for example

class in assembly:

namespace test {     public class class1     {         public string[] allnamespace()         {             return assembly.getexecutingassembly().gettypes().select(x => x.namespace).toarray();         }     } } 

code in main project:

namespace consoleapplication1 {     class program     {         static void main(string[] args)         {             var util=new class1();             console.writeline(string.join(",",util.allnamespace()));//return test             console.readkey();         }     } } 

return "test" want contain consoleapplication1 namespace.

use assembly.getcallingassembly instead of assembly.getexecutingassembly , should consoleapplication1-assembly.

you namespaces of assembly, sure contain consoleapplication1, not only.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -