CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Feb 2006
    Posts
    127

    Getting Interfaces and Methods from DLL

    Hello, I have a DLL that contains several interfaces. I am trying to get the function signatures of all the functions that are implemented in these interfaces.

    If anybody could show me an easy way how to do this right, I would really appreciate it.

  2. #2
    Join Date
    Jul 2006
    Posts
    297

    Re: Getting Interfaces and Methods from DLL

    Try to download RedGate's .NET Reflector you can get a free version of it off download.com.

  3. #3
    Join Date
    Feb 2006
    Posts
    127

    Re: Getting Interfaces and Methods from DLL

    well, you see, I have something like this:
    Code:
     Assembly asm = Assembly.LoadFile("mydll.dll");
     attributes = asm.GetExportedTypes();
     
     foreach (Type type in typelist)
     {
                    rt.Text += type.ToString();
                                   
                    MemberInfo[] memlist = type.GetMembers();
                    
                    rt.Text += "------Members-----";
                    rt.Text += "\n";
                    foreach (MemberInfo mem in memlist)
                    {
                        rt.Text += mem.ToString();
                        
                    }
                             
    }
    This gives me pretty much what I want, however, I figured that some of the interfaces do have base types and I can't read them.

    Any suggestions ?

  4. #4
    Join Date
    Jul 2006
    Posts
    297

    Re: Getting Interfaces and Methods from DLL

    Well you'll need to check the BindingFlags parameter of type.GetMembers(). It filters out a lot of the members and properties etc... if you just leave it with the default value.

  5. #5
    Join Date
    Feb 2006
    Posts
    127

    Re: Getting Interfaces and Methods from DLL

    Yea, I played around with that. No luck.

  6. #6
    Join Date
    Jul 2006
    Posts
    297

    Re: Getting Interfaces and Methods from DLL

    If you want the base class members do this

    Code:
    type.BaseType.GetMembers()

  7. #7
    Join Date
    Feb 2006
    Posts
    127

    Re: Getting Interfaces and Methods from DLL

    Thanks for your help. My problem was that I was actually not looking for a base type but rather a sub type.

    Thanks for your help though.

  8. #8
    Join Date
    Mar 2004
    Location
    33°11'18.10"N 96°45'20.28"W
    Posts
    1,808

    Re: Getting Interfaces and Methods from DLL

    reflector will give you types derived from your interfaces (assuming they're in the dll you're speaking of).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured