tags:

views:

84

answers:

4

The title says it all...

+7  A: 

Because the DLL contains metadata about all the types, methods etc. Even the actual code is in IL rather than native code.

Basically a .NET binary is still at a higher level than a native binary, and contains a lot more information about what's in there. That's what allows Reflection to work.

Jon Skeet
So, is it accurate to say that C# gets compiled then? I'm asking because if I understand what you're saying, the IL then gets interpreted, right?
Esteban Araya
If i understand it correctly, IL is JIT compiled to the proper machine code as necessary.
RCIX
JIT = Just-In-Time compiler.
Robert Harvey
Actually, both are true. On almost all .NET implementations, it is JIT compiled. But on "Micro Framework" it is interpreted. You aren't hugely likely to see Micro Framework much ;-p
Marc Gravell
Mono also has a bytecode interpreter, and IIRC can be forced to use it via command line switches.
Pavel Minaev
A "mixed" assembly can contain both managed and unmanaged code.
Dave Van den Eynde
A: 

It depends.

A DLL contains a list of functions exported, but these can be simply assigned a number, a name, or they can be assigned a mangled C++ name. The latter can give some insight in the function's parameters, but data structures, calling conventions and other required attributes are generally not documented.

If it's a COM DLL, there's a possibility that it contains a Type Library as a resource, but this is not guaranteed. In that case, .NET can import the library quite automatically.

A Type Library can also be included in a non-COM DLL, but this is not a widespread practice.

If you have a compiled DLL designed to be called from a non-COM, non-managed environment, you'll need to translate the header files that should be included with the DLL.

Dave Van den Eynde
I believe the question is specific to .NET, so the C++/COM side - while interesting and accurate - doesn't really apply.
Marc Gravell
This question is a response to my comment about another question regarding headers, so no, I don't think it's specific to .NET DLL's.
Dave Van den Eynde
+1  A: 

I'm not sure if that is what you are asking about, but I can only recommend the free tool .NET Reflector that lets you explore any compiled .NET assembly.

These days, I use it much more than I use even the published MSDN documentation, because it's much faster to navigate around in, and more informative to boot.

Mark Seemann
Not really what he's asking, but nice try anyway.
Robert Harvey
I don't think it was apparent just what he was asking about, which was also why I qualified my answer by "I'm not sure if that is what you are asking about".
Mark Seemann
A: 

One Word: Reflector

Abhijeet Patel
Bzzt! Try again.
Robert Harvey
Are you saying that Reflector will not provide exploration of metadata?
Abhijeet Patel