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. Design and specific code suggestions for reflection and access base class

Design and specific code suggestions for reflection and access base class

Scheduled Pinned Locked Moved C#
comdesignhelptutorialquestion
1 Posts 1 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.
  • M Offline
    M Offline
    MichCl
    wrote on last edited by
    #1

    I'm refactoring some code, and I'm trying to figure out if it's best to to access a base class method using reflection, or if I should access the child class. I definitely need to figure out how to access the base class to set up my form with data (see GetProgControl below). Does anyone know how to do this? I should probably be accessing a method in the child class to access the method in the parent class from the child class, since I am refactoring so I can add some child-specific methods later. The parent class will be common across several projects and classes. The child class will be pushing some group box and comboBox info up to the parent's form, with data. The main form is the base class' form, which I get the control of using GetProgControl using reflection below; however this isn't working since I used to do this when the parent class was what I was accessing directly. I've looked at the following links: http://stackoverflow.com/questions/12051/calling-base-constructor-in-c-sharp[^] http://stackoverflow.com/questions/5558868/printout-the-method-name-of-a-derived-class-by-calling-method-of-a-base-class[^] http://stackoverflow.com/questions/2267277/get-private-properties-method-of-base-class-with-reflection[^] My code, which is still set up to access the base class from before instead of the child class, looks like this: frmUseFrm.cs: //in preparation to add tabs to Generic's form (worked fine before generic became parent class)

    if (controls[i] == null)
    {
    try
    {
    _assembly = Assembly.LoadFrom(programDll);
    _type = _assembly.GetType("CrWr.ProgControl"); //problem here?
    _objectInstance = Activator.CreateInstance(

    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