asp.net - 在 .NET 4 下编译时出现 "An entry with the same key already exists"

标签 asp.net .net-4.0 asp.net-4.0

我正在尝试将 ASP.NET 应用程序升级到 .NET 4,但我网站上的一个页面包含一个异常:

Argument Exception: an entry with the same key already exists".



可能导致此问题的 ASP.NET 4 有何不同?

enter image description here

一种解决方案

不知道为什么,但设置 clientIDMode="Predictable"而不是 Static似乎避免了这个异常消息。

最佳答案

我遇到了同样的问题并修复了它。

我浏览了整个 ASPX 页面,发现与另一个具有相同 ID 的 ASP.NET 控件。

我也测试了这个修复,发现任何与页面上的另一个控件冲突的控件都会导致这个错误。

<asp:Label ID="FailureText" runat="server" EnableViewState="False" ClientIDMode="Static" />

<asp:Label ID="FailureText" runat="server" EnableViewState="False" ClientIDMode="Static" />

当您在同一页面上复制/粘贴元素时会发生这种情况。

关于asp.net - 在 .NET 4 下编译时出现 "An entry with the same key already exists",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4554156/

相关文章:

ASP.net 这是预编译工具生成的标记文件,不要删除

asp.net - 如何在 ASP.NET 中隐藏页面名称和查询字符串?

c# - 如何更改 CreateUserWizard 控件的布局?

asp.net - 如何以编程方式生成空白图标?

c# - 如何使用 C# 从 ASP.Net 中的数据库中获取最新记录?

localization - 如何强制 .NET4 及其工具使用英语进行豁免和其他消息

c# - ManualResetEvent(Slim), Semaphore(Slim) 和 ReaderWriterLock(Slim) 的用法和实现的区别

c# - ASP.Net C# 路由; HTTP处理器;和 HttpModule 不工作

asp.net - WPF 初学者说明

c# - VSPerfReader.dll 文件无法加载 VS2013