Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Use of Reflection

Use of Reflection

Scheduled Pinned Locked Moved C#
questioncsharp
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Ashwani_kumar
    wrote on last edited by
    #1

    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

    E S L C 4 Replies Last reply
    0
    • A Ashwani_kumar

      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

      E Offline
      E Offline
      emran834
      wrote on last edited by
      #2

      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

      S 1 Reply Last reply
      0
      • A Ashwani_kumar

        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

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • E emran834

          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

          S Offline
          S Offline
          S Senthil Kumar
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          • A Ashwani_kumar

            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

            L Offline
            L Offline
            leppie
            wrote on last edited by
            #5

            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(){}
            }

            xacc.ide-0.1.2.3
            Now with full keyboard customization

            1 Reply Last reply
            0
            • A Ashwani_kumar

              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

              C Offline
              C Offline
              Colin Angus Mackay
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups