Use of Reflection
-
I have studied reflection in .Net. Through reflection we can get the entire information of assembly and also able to generate the dynamic assemblies. But what is the practical use of Reflection. Where we need to generate dynamic assemblies? Ashwani
-
I have studied reflection in .Net. Through reflection we can get the entire information of assembly and also able to generate the dynamic assemblies. But what is the practical use of Reflection. Where we need to generate dynamic assemblies? Ashwani
Hi, May be there could be some good use of this feature but to me, it is tooooooooo much disappointing feature of .NET , Now, Whatever program we are making, other people can see the source code of our program through this feature, what could be worse feeling than this for a programmer. emran
-
I have studied reflection in .Net. Through reflection we can get the entire information of assembly and also able to generate the dynamic assemblies. But what is the practical use of Reflection. Where we need to generate dynamic assemblies? Ashwani
The most practical use of reflection I've found is for supporting plugin architectures. You can load any arbitrary assembly and iterate through the types, insantiate them and do all sorts of operations you want on them. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
Hi, May be there could be some good use of this feature but to me, it is tooooooooo much disappointing feature of .NET , Now, Whatever program we are making, other people can see the source code of our program through this feature, what could be worse feeling than this for a programmer. emran
Reflection doesn't allow you to look at the source code, it only allows you access to information about types in an assembly and provides an API to do things with them. Disassemblers work by looking for the metadata information in the executable and reverse engineering IL back to the source language. This is possible because .NET is a managed environment and binaries must contain metadata and high level code to be able to be executed. Regards Senthil _____________________________ My Blog | My Articles | WinMacro
-
I have studied reflection in .Net. Through reflection we can get the entire information of assembly and also able to generate the dynamic assemblies. But what is the practical use of Reflection. Where we need to generate dynamic assemblies? Ashwani
Ashwani_kumar wrote:
But what is the practical use of Reflection.
The use of reflection in base classes to find out whats happening in the inherit class is very practical, eg:
class Menu : Attribute {}
abstract class A
{
// in ctr look for methods containing Menu
// then simply USE that info for your use
}class B
{
[Menu]
void Foo(){}
} -
I have studied reflection in .Net. Through reflection we can get the entire information of assembly and also able to generate the dynamic assemblies. But what is the practical use of Reflection. Where we need to generate dynamic assemblies? Ashwani
Ashwani_kumar wrote:
But what is the practical use of Reflection.
There are many uses of reflection. NUnit uses reflection to work out what unit tests to run, and also how to interpret some of the results (for example, you can attribute a test with [ExpectesException()] which is also finds through reflection) Serializing and Deserializing classes uses reflection to build or extract information from the XML file. DotNetNuke uses reflection to take information from the database and populate the business objects. A more powerful example of the same idea is NHibernate. Reflection is useful in factory patterns in order to instantiate the correct class. The list goes on and on and on. ColinMackay.net "Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius "If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell