Finding the class that contains a method in an assembly.
using System;
using System.Reflection;
using System.Collections;
class MainClass {
public static void Main(string[] args) {
SearchForMethod(args[0], args[1]);
}
public static void SearchForMethod(string AssemblyName,string MethodName) {
Assembly assembly = Assembly.LoadFrom(AssemblyName);
if (assembly == null) {
Console.WriteLine(AssemblyName);
return;
}
foreach (Type t in assembly.GetTypes()) {
if (t.IsClass == false)
continue;
foreach (MethodInfo m in t.GetMethods()) {
if (m.Name == MethodName) {
Console.WriteLine("Class {0} contains method",
t.FullName);
}
}
}
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
|