Asp.net TreeView控件中的模糊引用

Asp.net TreeView控件中的模糊引用,asp.net,Asp.net,我试图在Visual Studio 2008中使用TreeView控件运行web应用程序,但出现以下错误: “TreeNodeCollection”是一个模棱两可的词 参考 'System.Web.UI.WebControl.TreeNodeCollection' 和 'Microsoft.Web.UI.WebControl.TreeNodeCollection' 有人能帮我吗?如果您知道要用于节点集合的名称空间,只需将完整名称空间放在TreeNodeCollection对象前面,如下所示: M

我试图在Visual Studio 2008中使用TreeView控件运行web应用程序,但出现以下错误:

“TreeNodeCollection”是一个模棱两可的词 参考 'System.Web.UI.WebControl.TreeNodeCollection' 和 'Microsoft.Web.UI.WebControl.TreeNodeCollection'


有人能帮我吗?

如果您知道要用于节点集合的名称空间,只需将完整名称空间放在TreeNodeCollection对象前面,如下所示:

Microsoft.Web.UI.Controls.TreeNodeCollection myNodeCollection=新建Microsoft.Web.UI.Controls.TreeNodeCollection()

您有对两个库“System.Web.UI.WebControls”和“Microsoft.Web.UI.WebControls”的引用(使用)。他们每个人都有TreeNodeCollection类。要解决此问题,必须在代码中指定完整引用:

System.Web.UI.WebControls.TreeNodeCollection collection = null;
也可以为此库指定别名:

using MWC = Microsoft.Web.UI.WebControls;
using SWC = System.Web.UI.WebControls;

SWC.TreeNodeCollection collection = null;