Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET Web窗体:对来自不同命名空间的Web控件使用相同的标记前缀_C#_Asp.net_Visual Studio_Webforms - Fatal编程技术网

C# ASP.NET Web窗体:对来自不同命名空间的Web控件使用相同的标记前缀

C# ASP.NET Web窗体:对来自不同命名空间的Web控件使用相同的标记前缀,c#,asp.net,visual-studio,webforms,C#,Asp.net,Visual Studio,Webforms,我在Web.config中遇到过如下情况: <add tagPrefix="a" assembly="WebApplication1" namespace="WebFormsApplication1.Controls1" /> <add tagPrefix="a" assembly="WebApplication1" namespace="WebFormsApplication1.Controls2" /> 下面是VS为该页生成的损坏的.designer.cs文件请注意

我在Web.config中遇到过如下情况:

<add tagPrefix="a" assembly="WebApplication1" namespace="WebFormsApplication1.Controls1" />
<add tagPrefix="a" assembly="WebApplication1" namespace="WebFormsApplication1.Controls2" />
下面是VS为该页生成的损坏的.designer.cs文件请注意,它对两个控件都使用Controls2命名空间,尽管Control1位于Controls1命名空间中:

protected global::WebFormsApplication1.Controls2.WebCustomControl1 Control1;
protected global::WebFormsApplication1.Controls2.WebCustomControl2 Control2;

它看起来像第二个在我过去需要它的情况下,我删除了设计器文件并手动声明了代码中的所有控件


可能还有一种方法,但我不记得如何确切地告诉设计器不要在设计器文件中生成这些特定控件。然后手动将它们添加到代码隐藏中

不要。由于命名空间阴影,它可能导致不可预测的结果。
protected global::WebFormsApplication1.Controls2.WebCustomControl1 Control1;
protected global::WebFormsApplication1.Controls2.WebCustomControl2 Control2;
<%@ Register TagPrefix="a" Namespace="WebFormsApplication1.Controls2" Assembly="WebFormsApplication1" %>
<%@ Register TagPrefix="a" Namespace="WebFormsApplication1.Controls" Assembly="WebFormsApplication1" %>