c# - 我需要帮助确定一种编程技术,以便我可以研究和修复它

标签 c# asp.net compiler-errors language-features assembly-references

代码:

父控件.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ParentControl.ascx.cs" 
Inherits="ParentControl" %>
<%@ Register Src="~/ChildControl.ascx" TagPrefix="Prefix" TagName="ChildControlTag" %>

父控件.ascx.cs
public partial class ParentControl : UserControl
{
   List<ASP.childcontrol_asxc> controlList = new List<ASP.childcontrol_asxc>();
   ... inside a public property setter ...
   var control = new ASP.childcontrol_ascx();  // <ABC> what the heck is this reference?
   controlList.Add(control);
   ...
}

子控件.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ChildControl.ascx.cs" 
Inherits="ChildControl" %>
<asp:Repeater ID="childRepeater" runat="server" EnableViewState="false" 
ViewStateMode="Disabled">

ChildControl.ascx.cs
public partial class ChildControl : UserControl
{
   ...

   protected void Page_Load(object sender, EventArgs e)
   {
      childRepeater.DataSource = xyz;  // <XYZ> crashes if I don't use the weird reference  
   }
}

问题:

我不明白标有 <ABC> 的引用评论是什么是所有关于。那不是我定义的类……但 Intellisense 不会提示。如果我按 F12在它上面,它带我到<%@ Control ... %>标记位于 ChildControl.ascx 顶部,而不是 ChildControl.ascx.cs 中的控件定义。
我不明白这个控件的其他版本是什么,为什么它在 ASP 命名空间中,或者直接使用它而不是控件的含义是什么。更糟糕的是,这在我的本地工作站上编译得很好,但在我们用于 CI 的 TFS 服务器上引发了编译器错误。

问题:

有谁知道这种使用/引用自定义用户控件的方法的名称,和/或有我可以查看的链接/信息以更好地处理这是什么以及含义是什么?我一直无法通过谷歌找到任何有用的东西。虽然修复/解决方法会很棒 - 我仍然希望能够研究该技术。

探索:

我尝试用实际的类名替换用法,而不是奇怪的 ASP.class_ascx引用...如果我这样做,它编译得很好,但不幸的是它在运行时失败。似乎其他引用更改了它与 asp.NET 生命周期的交互方式 - 在子控件的 aspx 中定义的服务器控件在 Page_Load() 中为空。子控件(标记为 <XYZ> )。怪下ASP.control_ascx引用方法,中继器在到达 Page_Load() 时被正确定义的 child 控制,但我不明白为什么。

杂项:

该项目在我的本地工作站上使用 Roslyn 编译器,通过 DotNetCompilerPlatform NuGet package但我相信它只是在 CI 服务器上使用 VS/TFS 2015 内置编译器。这可以解释为什么 TFS 会抛出编译器错误 - 它告诉我 The type or namespace name 'usercontrol_ascx' does not exist in the namespace 'ASP' (are you missing an assembly reference?) .我正在考虑将 TFS 配置为使用 NuGet 包中的编译器,然后希望它可以编译 - 但这仍然很奇怪,我想理解它。

最佳答案

这是 ASPX 文件编译到的类。它继承您的类并添加呈现您的 ASPX 内容的代码。

关于c# - 我需要帮助确定一种编程技术,以便我可以研究和修复它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48550547/

相关文章:

c# - 公开 LINQ 查询的 protected 集合

c# - 在 C# 中获取访问者 AD 用户名

c# - 无法从 App.config 引用变量

c++ - 在#include 语句中使用垃圾字符没有编译器错误

c# - 类属性中的字典有什么问题?

c# - 使用 C# 查询 MariaDB 数据库

c# - 图表控件内部数据列表

C#,如何获取网页内容?

asp.net - ASP.NET 应用程序中的 Google 桌面或索引文本文件搜索

android - 错误 : cannot find symbol static runOnUiThread