繁体   English   中英

ASP.NET Page指令:从备用程序集继承代码隐藏吗?

[英]ASP.NET Page directive: inherit codebehind from alternate assembly?

是否可以将ASPX Page指令的Inherits属性设置为任意程序集中的类?

我需要修改丢失源代码的ASP.NET(1.1)应用程序。 在一个新程序集(foo2.dll)中,我创建了一个替换代码隐藏类,该类从网站的代码隐藏程序集(foo.dll)中的原始类派生而来。 将Page指令的Inherits属性设置为新的类名称似乎很容易,但是当我这样做时,Web服务器却给我提供了Could not load type 'Foo2.checkout2' 我在Web.config的<assemblies>部分中引用新程序<assemblies>

我没有在文档中看到任何内容表明该方案不受支持,但我也不确定。

原版的

<%@ Page Inherits="Foo.checkout" language="c#" Codebehind="checkout.aspx.cs" AutoEventWireup="false" %>

<%@ Page Inherits="Foo2.checkout2" CodeFile="checkout2.aspx.cs" CodeFileBaseClass="Foo.checkout" language="c#" Codebehind="checkout.aspx.cs" AutoEventWireup="false" %>

是的,那是可能的。 您必须添加这样的参考 在此处输入图片说明

它没有更改web.config,但我在.csproj <ItemGroup />部分中有这样的引用

<Reference Include="WebApplication2, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>..\WebApplication2\bin\WebApplication2.dll</HintPath>
    </Reference>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM