Home All Groups Group Topic Archive Search About

'Function A' is not a member of 'Class 1'

Author
19 Oct 2007 8:41 PM
AlBruAn
I have a class named CheckVoucherRequest and within it, I have a function
declared thusly:
Public Overloads Shared Function RetrieveAllInfoForVoucherRequests(ByVal
areaID As Integer)

I'm trying to access info for the voucher requests by calling the function
as follows:
Dim gridSource As List(Of CheckVoucherRequest) =
CheckVoucherRequest.RetrieveAllInfoForVoucherRequests(areaID);
however, the compiler errors out by stating that:
'RetrieveAllInfoForVoucherRequests' is not a member of 'CheckVoucherRequest'.

If I select Class View from the menu, it very plainly shows the routine to
be a public member of CheckVoucherRequest.  What gives?  Why doesn't the
caller recognize it?

Author
19 Oct 2007 8:52 PM
Jon Skeet [C# MVP]
AlBruAn <albr***@hotmail.com.> wrote:
Show quote
> I have a class named CheckVoucherRequest and within it, I have a function
> declared thusly:
> Public Overloads Shared Function RetrieveAllInfoForVoucherRequests(ByVal
> areaID As Integer)
>
> I'm trying to access info for the voucher requests by calling the function
> as follows:
> Dim gridSource As List(Of CheckVoucherRequest) =
> CheckVoucherRequest.RetrieveAllInfoForVoucherRequests(areaID);
> however, the compiler errors out by stating that:
> 'RetrieveAllInfoForVoucherRequests' is not a member of 'CheckVoucherRequest'.
>
> If I select Class View from the menu, it very plainly shows the routine to
> be a public member of CheckVoucherRequest.  What gives?  Why doesn't the
> caller recognize it?

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

(And I'm fine with it being a VB.NET example, of course :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Author
19 Oct 2007 9:20 PM
AlBruAn
"Jon Skeet [C# MVP]" wrote:
> Could you post a short but complete program which demonstrates the
> problem?
>
> See http://www.pobox.com/~skeet/csharp/complete.html for details of
> what I mean by that.
>
> (And I'm fine with it being a VB.NET example, of course :)
Super!  Saves me the time of converting it to C# and hunting down all the
missing ; and wondering why ( ) won't work for holding an indexer's value. :)
>
> --
> Jon Skeet - <sk***@pobox.com>
> http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
> If replying to the group, please do not mail me too
>

Company's internet policy won't allow me access to your site :( 
Anyway, abbreviated code-behind for my web form is as follows:
Imports Bcbst.IM.FRO.BusinessObjects
Imports Bcbst.IM.FRO.BusinessObjects.UserControl
Imports Bcbst.IM.Common.DataAccessLayer
Imports Bcbst.IM.FRO.Common
Imports Microsoft.Win32
Imports System.Diagnostics
Imports System.Collections
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Data.SqlClient
Imports System.Net

Partial Class CheckVouchers_CheckVoucherApprovals
    Inherits System.Web.UI.Page

    Private currentUser As BcbstUser = Nothing
    Private areaID As Integer = Null.NullInteger

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

        If Not Page.IsPostBack Then
            ' Validate user's permissions
            currentUser =
BcbstUser.RetrieveUserByBcbstId(My.User.Name.ToLower.Replace("bcbst\",
String.Empty))

            areaID = currentUser.AreaId

            Dim keyNames As String() = {"ReceiptId"}

            Dim gridSource As List(Of CheckVoucherRequest) = _
            CheckVoucherRequest.RetrieveAllInfoForVoucherRequests(areaID)
            gridVoucherRequests.DataSource = gridSource
            gridVoucherRequests.DataKeyNames = keyNames
            gridVoucherRequests.DataBind()

        End If
    End Sub
End Class


Here's an abbreviated copy of my business object class:
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration
Imports System.Collections
Imports System.Collections.Generic
Imports System.Web.UI

Imports Bcbst.IM.Common.DataAccessLayer
Imports Bcbst.IM.FRO.Common

Namespace Bcbst.IM.FRO.BusinessObjects

    <Serializable()> _
    Public Class CheckVoucherRequest

#Region " Members "
        Private _ReceiptID As Integer = -1
        Private _EntityPaidID As String = String.Empty
        Private _EntityTypeID As Integer = -1
        Private _EntityTypeName As String = String.Empty
        Private _ClaimNumber As Integer = -1
        Private _AmountRequested As Decimal = Null.NullDecimal
        Private _VoucherReasonCode As String = String.Empty
        Private _VoucherReason As String = String.Empty
        Private _EntityType As String = String.Empty
        Private _AreaID As Integer = -1
        Private _WriteErrors As List(Of CheckVoucherError) = New List(Of
CheckVoucherError)

        Private Shared _ConnString As String = _
            ConfigurationManager.ConnectionStrings("FROMain").ConnectionString
#End Region

        Public Shared Function RetrieveAllInfoForVoucherRequests(ByVal areaID As
Integer) 'As List(Of CheckVoucherRequest)
            Dim requestList As New List(Of CheckVoucherRequest)

            Dim dr As SqlDataReader = SqlDataAccess.ExecuteReader(_ConnString, _
            "CheckVoucher.RetrieveInfoForAllRequests", areaID)

            While dr.Read()
                Dim info As New CheckVoucherRequest(dr("ReceiptID"), _
                dr("EntityTypeID"), dr("EntityID"), _
                Null.SetNull(dr("ApprovalUserID"), Null.NullString), _
                Null.SetNull(dr("ApprovalDate"), Null.NullDate), _
                CheckVoucherReason.RetrieveByCode(dr("CheckVoucherReasonCode"),
areaID).ToString(), _
                Null.SetNull(dr("ApprovalDeniedReason"), Null.NullString), _
                dr("RequestedAmount"))

                requestList.Add(info)
            End While
            Return requestList
        End Function
    End Class
Author
19 Oct 2007 9:37 PM
Jon Skeet [C# MVP]
AlBruAn <albr***@hotmail.com.> wrote:
Show quote
> "Jon Skeet [C# MVP]" wrote:
> > Could you post a short but complete program which demonstrates the
> > problem?
> >
> > See http://www.pobox.com/~skeet/csharp/complete.html for details of
> > what I mean by that.
> >
> > (And I'm fine with it being a VB.NET example, of course :)

> Super!  Saves me the time of converting it to C# and hunting down all the
> missing ; and wondering why ( ) won't work for holding an indexer's value. :)

:)

> Company's internet policy won't allow me access to your site :( 

Rats.

What I'd really like to see is a version of the code which we can
compile and run ourselves. In other words, it shouldn't be code behind
for a web project (too much hassle to set up) - a simple console
project is easiest. It also shouldn't need to use any classes beyond
the ones shown in the code - after all, we don't need to *do* anything
with the code.

I'd start off by taking your existing business objects library (I'm
assuming it's in its own assembly?) and trying to call the method in
question from a console app. That should give you some more information
about where the problem lies.

One *possible* cause: I don't suppose you've got a property or other
member of your code-behind called CheckVoucherRequest, have you?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

AddThis Social Bookmark Button