I have two dll files Lets say DataLayer.dll and ProcessLayer.dll. DataLayer.dll has a Class called MyClass like below:
public class MyClass
{
public string name;
public int age;
public string aadhar;
}
and I have refereed DataLayer.dll in second assembly ProcessLayer.dll which has one method with input parameter as MyClass.
using DataLayer;
namespace ProcessLayer
{
public class Process
{
public int GetMyClass(MyClass objMy)
{
return objMy.age;
}
}
}
How can I read all method parameters from ProcessLayer.dll
using reflection? I am using
Assembly assembly = Assembly.LoadFile(@"C:\ProcessLayer.dll");
foreach (Type _type in assembly.GetTypes())
{
foreach (var method in _type.GetMethods())
{
var parameters = method.GetParameters();
}
}
and got an error when try to execute method.GetParameters();
statement.
Can you please help me ?
how to get it with Mono.cecil any idea?
You need to load the assembly, then get the types, then get the methods for the type you are after.
If you need a type from another assembly, then you can load this in, you may need to instantiate it too.