简体   繁体   中英

How can I get a list of public exports from a .Net DLL?

I can use tools like "dumpbin" and "dll export" to see the public entrypoints ("exports") of standard win32 DLL's like Windows\SYSTEM32\GDI32.dll. But when I use these same tools on .Net DLLs all I see is something like

 2000 .reloc 2000 .rsrc 48000 .text

I have a C#/.Net DLL that provides entrypoints to control an industrial process and I want to check its public entry points against our documentation to ensure completeness of the public documentation. What tool shows public entry points for a .Net DLL?

I've tried Jetbrains DotPeek, which does a complete decompile of our DLL into C# source code, but that's overkill because it shows EVERYTHING and doesn't seem to have a summary mode where it just reports out public entry points.

I assume that by "entry points" you mean "public classes and methods"

How about using the visual Studio object browser?

  1. Create a test project
  2. Add a reference to the DLL you want to inspect.
  3. Double click on the reference to open the object browser
  4. Click the little "Gear" icon and uncheck "Show Private Members," "Show Protected Members," "Show Other Members" so you only see public stuff.
  5. Start browsing.

Just as a starting point only , how to list all public types from current assembly and list all public methods from them:

Assembly assembly = Assembly.GetExecutingAssembly();
var exports = 
assembly.GetExportedTypes()
        .SelectMany(type => type.GetMethods(BindingFlags.Instance | BindingFlags.Public)
                                .Select(member => new
                                {
                                    type.FullName,
                                    Member = member.ToString()
                                }))
        .ToList();

But this omits nested classes, properties and should be probably extended in few ways to suit question needs.

If you don't have VS - I like ILSpy. Microsoft now publishes it at the app store .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM