Created
February 27, 2012 11:23
-
-
Save leegould/1923145 to your computer and use it in GitHub Desktop.
Get Namespaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Reflection; | |
namespace GetNamespaces | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
if (args.Length < 1) | |
{ | |
ShowUsage(); | |
return; | |
} | |
string assFullPath = args[0]; | |
try | |
{ | |
Assembly a = Assembly.LoadFrom(assFullPath); | |
Console.WriteLine("Assembly Items:"); | |
foreach(var t in a.GetTypes().Select(t => t)) | |
{ | |
Console.WriteLine("Name:'{0}' Namespace:'{1}'",t.Name, t.Namespace); | |
} | |
} | |
catch(Exception e) | |
{ | |
Console.WriteLine("Error loading assembly: {0}", e.Message); | |
} | |
} | |
static void ShowUsage() | |
{ | |
Console.WriteLine("Show namespaces for assembly."); | |
Console.WriteLine("\tUsage: {0} [path]", AppDomain.CurrentDomain.FriendlyName); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment