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. .NET (Core and Framework)
  4. how dynamic is .NET

how dynamic is .NET

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharptutorialquestion
6 Posts 3 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.
  • T Offline
    T Offline
    thebread
    wrote on last edited by
    #1

    hey folks, can anyone tell me if it's possible to alter a enumeration or a class during runtime? for example adding an item to a enumeration or exchanging a method with another? if not, what can i do to customize the host application with a 'add-in' which is loaded by the host application? thanks for hints bernd

    G N 2 Replies Last reply
    0
    • T thebread

      hey folks, can anyone tell me if it's possible to alter a enumeration or a class during runtime? for example adding an item to a enumeration or exchanging a method with another? if not, what can i do to customize the host application with a 'add-in' which is loaded by the host application? thanks for hints bernd

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Specify an interface for the add-in, then create a library with a class that implements the interface. Now you can load the library dynamically, and use the interface to access the object without having to use reflection for everything.

      --- b { font-weight: normal; }

      T 1 Reply Last reply
      0
      • G Guffa

        Specify an interface for the add-in, then create a library with a class that implements the interface. Now you can load the library dynamically, and use the interface to access the object without having to use reflection for everything.

        --- b { font-weight: normal; }

        T Offline
        T Offline
        thebread
        wrote on last edited by
        #3

        hey Guffa, thanks. it's not that easy. i haven't the source code of the host application under my control :( btw. i wouldn't like to touch it. you say reflection...is reflection able to do things we speek about? till now i used reflection just "raedonly". regards, bernd

        G 1 Reply Last reply
        0
        • T thebread

          hey folks, can anyone tell me if it's possible to alter a enumeration or a class during runtime? for example adding an item to a enumeration or exchanging a method with another? if not, what can i do to customize the host application with a 'add-in' which is loaded by the host application? thanks for hints bernd

          N Offline
          N Offline
          Not Active
          wrote on last edited by
          #4

          Although it is a complicated procedure you can use code dom to create/insert dynamic code, though I'm not sure of the value of this in your case. Exchanging one method for another can be done using a pattern, possible strategy or adapter.

          only two letters away from being an asset

          T 1 Reply Last reply
          0
          • N Not Active

            Although it is a complicated procedure you can use code dom to create/insert dynamic code, though I'm not sure of the value of this in your case. Exchanging one method for another can be done using a pattern, possible strategy or adapter.

            only two letters away from being an asset

            T Offline
            T Offline
            thebread
            wrote on last edited by
            #5

            uiui, sounds crazy. the pattern should be implemented in the host application i think, isn't it? if i do the step to touch the code of the host application i haven't to go the long way round doing stuff with code dom and something like that. but this could be a powerfull plug-in mechanism...i'll give it a try later. thanks for your advice, bernd

            1 Reply Last reply
            0
            • T thebread

              hey Guffa, thanks. it's not that easy. i haven't the source code of the host application under my control :( btw. i wouldn't like to touch it. you say reflection...is reflection able to do things we speek about? till now i used reflection just "raedonly". regards, bernd

              G Offline
              G Offline
              Guffa
              wrote on last edited by
              #6

              thebread wrote:

              i haven't the source code of the host application under my control

              Then the answer is no. You can't do it using .NET. Anything is possible. You could alter the executable file to make changes in the program, but there is no support what so ever for this in .NET. You are totally on your own to fiddle with the byte codes. For an example, to replace a method you would either have to overwrite the code in the method, or add additional code for a method and change every call to the original method to use the new method instead. Are you up to the task? Have you done any assembler programming, for instance? I've done a lot of assembler programming and even machine code programming myself, but I would hesitate to try what you are suggesting...

              --- b { font-weight: normal; }

              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