locked
Finding all the references RRS feed

  • Question

  • HI all,
            Could any one help me out the problem I am facing with reflection. This is my need:

    I have a class (Class1) that has a method(Method1). This method calls another method(Method2) of another class(Class2) that is in some other file.

    Now using reflection in theClass1 and its method Method1,  I need to get the details of the Method2 of Class2.

    Is it possible? If Yes, please tell me how to achieve it.

    Thank you.




           
    Monday, November 17, 2008 4:47 AM

Answers

  • You cannot do this with Reflection.  You'll need a decompiler, something like Ildasm.exe or Red Gate's Reflector.  Nothing you could easily build into your own program.
    Tuesday, November 18, 2008 4:20 AM

All replies

  • It sounds that you're on the wrong track with this.  You cannot use Reflection to decompile code.  If you want to find out more about Class2.Method2(), you should use typeof(Class2).GetMethod("Method2").  If you cannot reference Class2 yourself, you could use Assembly.GetReferencedAssemblies() to find out what assemblies are referenced by the assembly that contains Class1 and Assembly.GetType() to get a Type instance for Class2.
    Monday, November 17, 2008 6:46 PM
  • Hi nobugz,
                   My case is more likely a generic one. I want to get all the methods that are referenced by Method1 of Class1 and not only Method2 of Class2. Is there any solution other than reflection?
    Tuesday, November 18, 2008 4:10 AM
  • You cannot do this with Reflection.  You'll need a decompiler, something like Ildasm.exe or Red Gate's Reflector.  Nothing you could easily build into your own program.
    Tuesday, November 18, 2008 4:20 AM
  • Thank You very much for spending your time.
    Tuesday, November 18, 2008 5:56 AM
  • I have downloaded Reflector and used it. It is amazing. I suggest one more tool that is one step ahead of Reflector. It is called NDepend. You can download it here:

    http://www.ndepend.com/Default.aspx

    but the problem is, it is not free. Only trial version is available for free.
    Friday, November 21, 2008 3:54 AM