Share via


is not accessible in this context because it is 'Friend'

Question

Tuesday, February 9, 2016 2:24 AM

Hi

I have a couple of classes as per code below at the end. When I try to access one of the classes in a third class as below;

    Public MustInherit Class MyClass

        Private Sub MySub

           Dim results As AvailabilityStaffCountList = AvailabilityStaffCountList.Load(...)

        End Sub

    End Class

I get the

AvailabilityStaffCountList.Friend Shared Function Load(...) As AvailabilityStaffCountList' is not accessible in this context because it is 'Friend'.

error. What am I missing?

Thanks

Regards

    Public Class AvailabilityStaffCount

       'Properties here

    End Class


    Public Class AvailabilityStaffCountList

        Public Sub New(results As IList(Of AvailabilityStaffCount))
            Me.Results = results
        End Sub

        Private m_Results As IList(Of AvailabilityStaffCount)
        Public Property Results() As IList(Of AvailabilityStaffCount)
            Get
                Return m_Results
            End Get
            Private Set(value As IList(Of AvailabilityStaffCount))
                m_Results = value
            End Set
        End Property

        Friend Shared Function Load(session As Session) As AvailabilityStaffCountList
            Dim objects As New List(Of AvailabilityStaffCount)(...)

            Return New AvailabilityStaffCountList(objects)
        End Function

    End Class

All replies (3)

Tuesday, February 9, 2016 2:38 AM âś…Answered

Hi,

Friend is accessible only from the same assembly. If AvailabilityStaffCountList is in an other dll or exe than MyClass this error will be thrown...

see:

https://msdn.microsoft.com/en-us/library/76453kax.aspx

Regards,

  Thorsten


Tuesday, February 9, 2016 4:12 AM | 1 vote

AvailabilityStaffCountList.Friend Shared Function Load(...)

That doesn't even make sense!

*****

Yahya, do you want to let's work through this or are you just going to ignore this one the same as you seem to do most of your other questions?

I'll be back in the morning. Let me know please...

Knowledge rests not upon truth alone, but upon error also. Carl Jung


Tuesday, February 9, 2016 4:39 AM

Hi Frank

I have moved all classes into the same project and it has worked.

Thanks

Regards