Wednesday, March 7, 2012

Add-Type issue with multi-assembly project

I have a project that loads plugins from a folder.  The assemblies are each loaded and parsed to catalog the methods in that assembly that contain a specific attribute.  This was easier than using a type check because it allowed me to use inheritance for my plug-ins as well as allow them to call others from the same assembly without exposing those publicly.

At any rate, my base class for these plug-in was building to a BIN\DEBUG in its own source tree.  Many of the other class were building to a common Bin\Debug.  In doing this they would copy the base assembly over.

When running in the application UI, the base class was loaded directly.  The other assemblies all resolved and used this reference.  When launching via PowerShell even after an Add-Type for the base class these assemblies could not be loaded.  They would throw System.Reflection.ReflectionTypeLoadException" Unable to load one or more of the requested types" and suggest that details be pulled from "LoaderExceptions
".

Changing the build path for the base class assembly to the same as the other and having the other refrences to this location seems to have resolved the issue.