I am trying to write a pluggable system in which assemblies can be deleted in a folder that ASP.NET does not know about. This plug-in system works fine for ASP.NET MVC assemblies, but for old-school WebForm assemblers (where .aspxfiles are Inheritsderived classes System.Web.UI.Page) it System.Web.Compilation.BuildManageris responsible for compiling the .aspxfile into a dynamic assembly.
My problem is that BuildManagerit does not know anything about the assemblies inside my pluggable folder, and it seems I can do nothing to help it. If I do this:
BuildManager.GetType("PluginAssembly.DefinedType", true, true)
he throws. If I get a link to first Type, then try:
var instance = BuildManager.CreateInstanceFromVirtualPath(path, type);
it still throws, although I already went through a specific one Type, it should compile the file .aspx. Is there anything I can do to help BuildManagerfind the types needed to compile the file .aspx?
Update:
I took another step by looking at what it was actually doing BuildManager.GetType(). Having specified the assembly, the type is defined in (for example, "PluginAssembly.DefinedType, PluginAssembly") and then connected to the event System.AppDomain.CurrentDomain.AssemblyResolve, now I can find the assembly of the plugin and return it so that the BuildManager can successfully build the type. This does the following work with flying colors:
BuildManager.GetType("PluginAssembly.DefinedType, PluginAssembly", true, true)
However, this still fails:
var instance = BuildManager.CreateInstanceFromVirtualPath(path, type);
Even if the file .aspxnow has the same assembly reference in its directive Inherits:
<%@ Page Language="C#"
CodeBehind="Index.aspx.cs"
Inherits="PluginAssembly.DefinedType, PluginAssembly" %>
Received error:
" : CS0234: " DefinedType " " PluginAssembly "( ?)" :
Line 205:
Line 206: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 207: public class plugins_pluginassembly_dll_index_aspx
: global::PluginAssembly.DefinedType,
System.Web.SessionState.IRequiresSessionState,
System.Web.IHttpHandler {
Line 208:
Line 209: private static bool @__initialized;
, BuildManager.CreateInstanceFromVirtualPath() System.Web.Util.IWebObjectFactory, , . - , , BuildManager?