2010-02-15 25 views
2

我有一個ASP.NET 3.5 Web應用程序項目,我試圖實現可搜索的GridView。我最初是作爲一個網站開始項目,並將其轉換爲一個Web應用程序。轉換後,我的課程結束於文件夾Old_App_Code,名爲SearchGridView.vb。在項目級導入中指定的名稱空間或類型不包含公共成員

Imports System 
Imports System.Collections 
Imports System.Collections.Generic 
Imports System.ComponentModel 
Imports System.Text 
Imports System.Web 
Imports System.Web.UI 
Imports System.Web.UI.WebControls 
Imports System.Drawing.Design 


<Assembly: TagPrefix("MyApp.WebControls", "SearchGridView")> 
Namespace MyApp.WebControls 
#Region "TemplateColumn" 
Public Class NumberColumn 
Implements ITemplate 

    Public Sub InstantiateIn(ByVal container As System.Web.UI.Control) Implements  System.Web.UI.ITemplate.InstantiateIn 

    End Sub 
    End Class 
    #End Region 
    <ToolboxData("<{0}:SearchGridView runat=server></{0}:SearchGridView>")> _ 
    <ParseChildren(True, "SearchFilters")> _ 
    Public Class SearchGridView 
    Inherits GridView 

類文件繼續,但這是它的第一部分。

不幸的是,我收到錯誤消息 警告1項目級別中指定的名稱空間或類型Imports'MyApp.WebControls'不包含任何公共成員或無法找到。確保命名空間或類型已定義並且至少包含一個公共成員。確保導入的元素名稱不使用任何別名。 DielWebProj

在web.config中,我爲MyApp.WebControls提供了一個名稱空間標記,同時我還在.aspx頁面中包含了一個imports標記。

任何人都可以闡明爲什麼會出現這個錯誤,我會如何補救?

感謝, 希德

回答

1

我有一個大致類似的問題給你。我有一個使用自定義控件的網站項目,它繼承自GriView,位於app_code文件夾中。我收到了同樣的錯誤,但注意到它只是在我將第二個類或模塊添加到app_code後纔會發生,並且如果我將其刪除,它將消失。

因此,我目前的解決方法是將我的自定義控件作爲app_code的唯一佔有者。

一個選項可能是讓自己的項目的控制部分,並將其添加爲我們的網站/應用程序的參考?

我會更新這個,如果我能找到一個體面的解決方案。

編輯: 嗯,在我的情況下,這是因爲我使用的控件是用C#編寫的,而項目的其餘部分和我添加到app_code的類都是用VB編寫的。 app_code文件夾被編譯爲單個程序集,因此不同語言的類不能共享它,除非您創建單獨的子文件夾並執行一些配置文件jiggerypokery。更多詳情here

相關問題