Help System.Web.Compilation.BuildManager find a type in a non-referenced assembly
- by asbjornu
I'm trying to write a plug-in system where assemblies can be dropped in a folder that ASP.NET has no knowledge about. This plug-in system works fine for ASP.NET MVC based assemblies, but for old-school WebForm assemblies (where the .aspx files Inherits the System.Web.UI.Page derived classes) System.Web.Compilation.BuildManager is responsible for compiling the .aspx file into a dynamic assembly.
My problem is that the BuildManager knows nothing about the assemblies within my plug-in folder and it seems to be absolutely nothing I can do to help it. If I do:
BuildManager.GetType("Type.Defined.In.Plugin.Assembly", true, true)
it throws. If I first get a reference to the Type and then try:
var instance = BuildManager.CreateInstanceFromVirtualPath(path, type);
it still throws, even though I've now passed in the specific type it needs to compile the .aspx file. Is there anything I can do to help BuildManager find the types it needs to compile the .aspx file?