2010-08-17 29 views
0

我試圖運行在Visual Studio 2008中的TreeView控件的Web應用程序,我得到這個錯誤:明確的引用在TreeView控件

'TreeNodeCollection' is an ambiguous reference between 'System.Web.UI.WebControls.TreeNodeCollection' and 'Microsoft.Web.UI.WebControls.TreeNodeCollection'

誰能幫助我?

回答

1

那麼,如果你知道哪些命名空間是您要使用的節點集合的一個,只是把完整的命名空間中TreeNodeCollection對象的面前,就像這樣:

Microsoft.Web.UI.Controls。 TreeNodeCollection myNodeCollection = new Microsoft.Web.UI.Controls.TreeNodeCollection();

1

您有兩個庫「System.Web.UI.WebControls」和「Microsoft.Web.UI.WebControls」的引用(usings)。他們每個人都有類TreeNodeCollection。要解決問題你必須在代碼中指定完整的參考:

System.Web.UI.WebControls.TreeNodeCollection collection = null; 

或者你也可以到這個庫指定別名:

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

SWC.TreeNodeCollection collection = null;