views:

10

answers:

0

I have a VirtualPathProvider that is loading my aspx file content from a DB. All seems to be well and good except when my aspx file has a reference to a namespace or assembly that is not explicitly mentioned in my web.config.

The solution seems easy right? Add assembly and import directives to the page... But that doesn't seem to work. I still get the following HttpCompileException:

    c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET 
Files\app.server\70480a40\2a773b44\App_Web_test.aspx.e7cf0b6b.mzeindht.0.cs(183): error CS0234: 
The type or namespace name 'Model' does not exist in the namespace 'MyApp.Data' (are you missing an assembly reference?)

Even though, in my test.aspx page saved in the DB I have:

<%@ Assembly Name="MyApp.Data" %>
<%@ Import Namespace="MyApp.Data" %>
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyApp.Data.Model.TestModel>" %>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
</asp:Content>

Now, I already know that MyApp.Data has already been loaded into the AppDomain (I've verified at runtime by checking AppDomain.CurrentDomain.GetAssemblies()) and I know that no failed request is getting made to load the MyApp.Data assembly (because I've bound to the AppDomain.ResolveAssembly event and it's not firing right before the exception occurs). Also, if I change the name in the assembly directory to MyApp.Data123 (a bogus name), the page bombs out trying to load the assembly.

If I remove the assembly directive from the page entirely, then I get the namespace The type or namespace name 'MyApp' could not be found...so having the assembly directive there does seem to help a little bit...

Any idea what I'm missing here? Thanks.