IsSubclassOf - Why does it do this?
-
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 theIsSubclassOf
reflection method. The sanity check fails unless I change theCopy local
property for plugin's reference to SimplePlugins.DLL to false. My question: Why doesn'tIsSubclassOf
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 -
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 theIsSubclassOf
reflection method. The sanity check fails unless I change theCopy local
property for plugin's reference to SimplePlugins.DLL to false. My question: Why doesn'tIsSubclassOf
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, 2013More 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.
-
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.
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 -
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, 2013For 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.