我有一个从数据库加载aspx文件内容的VirtualPathProvider。一切似乎都很好,除非我的aspx文件引用了web.config中没有明确提到的命名空间或程序集。
解决方案看起来很简单,对吧?将程序集和导入指令添加到页面...但这似乎并不管用。我仍然得到以下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?)尽管如此,在保存在数据库中的test.aspx页面中,我有:
<%@ 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>现在,我已经知道MyApp.Data已经加载到AppDomain中(我已经在运行时通过检查AppDomain.CurrentDomain.GetAssemblies()进行了验证),并且我知道加载MyApp.Data程序集没有发出失败的请求(因为我绑定了AppDomain.ResolveAssembly事件,并且它不会在异常发生之前立即触发)。此外,如果我将程序集目录中的名称更改为MyApp.Data123 (一个伪造的名称),页面将在尝试加载程序集时爆炸。
如果我从页面中完全删除程序集指令,那么我得到的名称空间的类型或名称空间名称'MyApp‘不能是found...so,其中的程序集指令似乎确实有一点帮助...
你知道我错过了什么吗?谢谢。
发布于 2011-11-23 06:36:44
可能存在重复的.NET VirtualPathProviders and Pre-Compilation
If a Web site is precompiled for deployment, content provided by a VirtualPathProvider
instance is not compiled, and no VirtualPathProvider instances are used by the precompiled
site.https://stackoverflow.com/questions/3649091
复制相似问题