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. IsSubclassOf - Why does it do this?

IsSubclassOf - Why does it do this?

Scheduled Pinned Locked Moved .NET (Core and Framework)
question
4 Posts 2 Posters 1 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.
  • realJSOPR Offline
    realJSOPR Offline
    realJSOP
    wrote on last edited by
    #1

    I'm writing an app that supports plugins, using the SimplePlugins library. Plugins live in a separate subfolder. Both the app and its plugins reference the SimplePlugins DLL. For the plugins, the SimplePlugins assembly performs a sanity check to ensure that the plugin module includes at least one object derived from PluginBase (that lives I the SimplePlugins assembly). So in the grand scheme of things, the app loads first, and uses the SimplePlugins creates a new app domain for each plugin assembly, and then performs said sanity check which calls the IsSubclassOf reflection method. The sanity check fails unless I change the Copy local property for plugin's reference to SimplePlugins.DLL to false. My question: Why doesn't IsSubclassOf find the specified derived type without setting Copy local to false? Is it because I'm crossing app domains? Is it because the plugin is loading a different copy of the SimplePlugins DLL?

    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
    -----
    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
    -----
    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

    M 1 Reply Last reply
    0
    • realJSOPR realJSOP

      I'm writing an app that supports plugins, using the SimplePlugins library. Plugins live in a separate subfolder. Both the app and its plugins reference the SimplePlugins DLL. For the plugins, the SimplePlugins assembly performs a sanity check to ensure that the plugin module includes at least one object derived from PluginBase (that lives I the SimplePlugins assembly). So in the grand scheme of things, the app loads first, and uses the SimplePlugins creates a new app domain for each plugin assembly, and then performs said sanity check which calls the IsSubclassOf reflection method. The sanity check fails unless I change the Copy local property for plugin's reference to SimplePlugins.DLL to false. My question: Why doesn't IsSubclassOf find the specified derived type without setting Copy local to false? Is it because I'm crossing app domains? Is it because the plugin is loading a different copy of the SimplePlugins DLL?

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

      M Offline
      M Offline
      Maarten1977
      wrote on last edited by
      #2

      More information is needed. - What is the base directory of the AppDomains? - How are you triggering the code in the AppDomain? - Is the SimplePlugins.DLL also stored in each plugin-subfolder? - Which assemblies are now loaded in the appdomain? Debug to find out the exact location. - 'Why doesn't IsSubclassOf find the specified derived type' - does not make sense. IsSubclassOf returns either true or false.

      realJSOPR 1 Reply Last reply
      0
      • M Maarten1977

        More information is needed. - What is the base directory of the AppDomains? - How are you triggering the code in the AppDomain? - Is the SimplePlugins.DLL also stored in each plugin-subfolder? - Which assemblies are now loaded in the appdomain? Debug to find out the exact location. - 'Why doesn't IsSubclassOf find the specified derived type' - does not make sense. IsSubclassOf returns either true or false.

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        maarten_oosterhoff wrote:

        - What is the base directory of the AppDomains?

        I don't see how that matters. The plugin DLL is in a subfolder of the app's folder.

        maarten_oosterhoff wrote:

        - How are you triggering the code in the AppDomain?

        Calling a method.

        maarten_oosterhoff wrote:

        Is the SimplePlugins.DLL also stored in each plugin-subfolder?

        Yes, but that's when it fails. If I don't copy it to that folder, it's fine.

        maarten_oosterhoff wrote:

        - Which assemblies are now loaded in the appdomain? Debug to find out the exact location.

        The app is in one domain, and the plugin is in another.

        maarten_oosterhoff wrote:

        - 'Why doesn't IsSubclassOf find the specified derived type' - does not make sense. IsSubclassOf returns either true or false.

        Yeah, I know. My statement indicates that it's returning false. I just want to know why it makes a difference.

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        M 1 Reply Last reply
        0
        • realJSOPR realJSOP

          maarten_oosterhoff wrote:

          - What is the base directory of the AppDomains?

          I don't see how that matters. The plugin DLL is in a subfolder of the app's folder.

          maarten_oosterhoff wrote:

          - How are you triggering the code in the AppDomain?

          Calling a method.

          maarten_oosterhoff wrote:

          Is the SimplePlugins.DLL also stored in each plugin-subfolder?

          Yes, but that's when it fails. If I don't copy it to that folder, it's fine.

          maarten_oosterhoff wrote:

          - Which assemblies are now loaded in the appdomain? Debug to find out the exact location.

          The app is in one domain, and the plugin is in another.

          maarten_oosterhoff wrote:

          - 'Why doesn't IsSubclassOf find the specified derived type' - does not make sense. IsSubclassOf returns either true or false.

          Yeah, I know. My statement indicates that it's returning false. I just want to know why it makes a difference.

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          M Offline
          M Offline
          Maarten1977
          wrote on last edited by
          #4

          For me, to try to solve your question, it was necessary to ask for some more info. Working with AppDomains and dynamically loading assemblies is tricky, and I need to know what it is exactly that is loaded in the AppDomain, and what the start-up parameters are of said AppDomain (like the base-directory). My apologies if this was not to your liking. Good luck solving your problem.

          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