如何从.dll检索方法名称? [英] How to retrieve the method name's from .dll ?

查看:65
本文介绍了如何从.dll检索方法名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!我需要从.dll中检索出现在指定位置的所有方法名称.我尝试使用反射,但是它提供了所有类文件中的所有方法,但我需要按dll中的类区分方法. >
很多的爱
Hemanth(laxmi)

Hi everyone! I need a to retrive all the method names from .dll which are present at specified location.I have tried to use reflection but it gives all the methods from all the class files but i need to differntiate methods by classes in dll.

Lots of Love
Hemanth(laxmi)

推荐答案

使用反射来获取Assembly中的类型.
然后使用反射获取该类型的方法.
Use reflection to get the types in the Assembly.
Then use reflection to get the methods for that type.
private static void ListTypes(Assembly myAssembly)
    {
    Type[] types = myAssembly.GetTypes();
    Console.WriteLine(@"Assembly """ + myAssembly.GetName().ToString() + @""" Contains " + types.Length + " types:");
    foreach (Type type in types)
        {
        Console.WriteLine("   >" + type.FullName);
        MethodInfo[] methods = type.GetMethods();
        foreach (MethodInfo mi in methods)
            {
            Console.WriteLine("       >" + mi.Name);
            }
        }
    }


这篇关于如何从.dll检索方法名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆