mardi 29 décembre 2015

How to get namespace, class, methods and its arguments with Reflection

I need to load the dll using reflection and have to get the namespace, class, methods and its arguments for that dll. Also, I need to write those information in a log file.

I have used the following code. But I got only up to class that has been written to log file.

Assembly dll = Assembly.LoadFile(@"D:\Assemblies\Myapplication.dll");
foreach (Type type in dll.GetTypes())
{
    var name = "Myapplication~" + type.FullName;
    File.AppendAllText("Assembly Details.log", "Myapplication~" + type.FullName + "\r\n\r\n");

    Console.WriteLine(type.FullName);
}

In the log file, the information needs to written as below.

Myapplication~namespace.class~method(arguments)

Eg:

Myapplication~copyassembly.class~Mymethod(String, Type)

Any suggestions would be greatly helpful.





Aucun commentaire:

Enregistrer un commentaire