Reflector doesn't show class implementation
Asked Answered
B

4

10

I'm trying to decompile a library but when I click on a class name or a method name, the implementation code is empty.

For example:

public bool MethodOne(string str)
{
    // nothing
}

What could it be?

Briony answered 20/11, 2009 at 21:32 Comment(5)
could be the method actually is empty...Queenhood
I know you placed the word public on your example method but could it be an abstract method or just an empty method to be overridden if needed?Economizer
It's a library that I use in a project and It works. It isn't an abstract or a virtual method. Is possible to "remove/hide" code from a library with an obfuscation method?Briony
@Randolpho: how can it be empty if it need to return something...?Asher
There are correct answers here; you should mark one.Brice
P
23

You may be trying to reflect reference assemblies used by Visual Studio to provide multi-targeting support. These assemblies are metadata-only and don't have any actual implementation.

If that is the case than you can use VSCommands 2010 extension to get path to the actual assembly with implementation.

assembly details http://vscommands.com/wp-content/uploads/2011/04/image12.png

Pibgorn answered 6/6, 2010 at 14:1 Comment(2)
This is the answer. The metadata only versions reside under "Reference Assemblies" under program files. You have to open the versions in windows\microsoft.net\framework\....Brice
Sadly, the link to the blog post doesn't work anymore. But this answer and the one from @Asher helped me a lot. On a side note: The "Show assembly details" feature of VSCommands does not appear in the feature list of newer versions of the extension (I haven't tried this extension yet).Reptilian
T
2

You might have opened a Reference Assembly or a PIA that doesn't have code in it.

The method body could actually be empty.

(Other possibilities?)

Thornie answered 20/11, 2009 at 21:35 Comment(1)
mmm I use it on a project and it works...Where could be the code? :PBriony
A
2

I have seen this with the VSSDK assemblies too.

It could be a public provided interface library, but the actual implementation is 'hidden' somewhere. (Maybe in the GAC?)

The basic train of thought is:

  1. Compile code against some 'stub' assembly
  2. When loaded in the application, the stub assembly is not resolved, but the actual one

I suggest you place a breakpoint in the debugger, and see what is the actual loaded assembly and where it is loaded from.

Asher answered 21/11, 2009 at 13:9 Comment(0)
F
0

What version of the .Net framwork is it using? There seems to be some issue with .net 4.0 assemblies where this happens ... or that is what some people in the forums are saying: Reflector Forum

Is there any IL?

Floorage answered 21/11, 2009 at 13:3 Comment(1)
My guess is, Red Gate hasn't finished that code yet. If you aren't using a pre-release of Reflector you might try it (red-gate.com/MessageBoard/viewforum.php?f=109)Floorage

© 2022 - 2024 — McMap. All rights reserved.