0

ReSharper (7.1.25.234) 在添加寄存器指令时做错了。

  1. 创造/Controls/ComplexField.ascx
  2. APageWithABunchOfFields.aspx中,指的是新控件:

    <%@ Page Title="A page with a bunch of fields" Language="C#" MasterPageFile="~/Layouts/Site.Master" %>
    <myproj:ComplexField runat="server" />
    
  3. ReSharper 提供生成一个<%@ Register %>指令,这会导致:

    <%@ Page Title="A page with a bunch of fields" Language="C#" MasterPageFile="~/Layouts/Site.Master" %>
    <%@ Register TagPrefix="myproj" Namespace="MyProject.Controls" Assembly="MyProject" %>
    <myproj:ComplexField runat="server" />
    

问题是,它不会找到或执行ComplexField.ascx(请注意,虽然ComplexField实例确实被构建了)。ReSharper应该生成的是:

<%@ Page Title="A page with a bunch of fields" Language="C#" MasterPageFile="~/Layouts/Site.Master" %>
<%@ Register TagPrefix="myproj" TagName="ComplexField" Src="~/Controls/ComplexField.ascx" %>
<myproj:ComplexField runat="server" />

换句话说,ReSharper 是通过命名空间而不是源路径注册控件。ComplexField.ascxReSharper 导致的问题是加载页面时ASP.NET 不执行文件!

这是 ReSharper 中的错误/缺失功能还是我对 Register 指令的理解有问题?

4

0 回答 0