views:

485

answers:

1

a funny problem ... i can't understand it..

let me show you what i have first :

'D:\ReportsOfficesSystem\ReportsOfficesBLL\BaseController.vb'
         ^                      ^                ^
     solution                 project         a vb class file

and

'D:\ReportsOfficesSystem\ReportsOfficesDAL\ReportsOfficesEntities.vb'
          ^                     ^                     ^
     the same solution         an other project       a vb class file

in ReportsOfficesEntities.vb:

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Web
Namespace ReportsOfficesModel
    Partial Class ReportsOfficesEntities
        Public Shared ReadOnly Property db() As ReportsOfficesEntities
            Get
                If HttpContext.Current IsNot Nothing Then
                    If HttpContext.Current.Session("context") Is Nothing Then
                        HttpContext.Current.Session.Add("context", New ReportsOfficesEntities())
                    End If
                    Return TryCast(HttpContext.Current.Session("context"), ReportsOfficesEntities)
                Else
                    Return New ReportsOfficesEntities()
                End If
            End Get
        End Property
    End Class
End Namespace

in BaseController.vb:

Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports ReportsOfficesDAL.ReportsOfficesModel
Imports System.Web
Namespace ReportsOfficesBLL
    Public Class BaseController
        Protected db As ReportsOfficesEntities = ReportsOfficesEntities.db
        Protected MultiEntity As Boolean = False
        Public Sub Save()
            db.SaveChanges()
        End Sub
        Public Sub Rollback(ByVal entity As [Object])
            db.Refresh(System.Data.Objects.RefreshMode.StoreWins, entity)
        End Sub
    End Class
End Namespace

and of course i added the references for both projects...

the error in BaseController.vb:

'ReportsOfficesDAL.ReportsOfficesModel.ReportsOfficesEntities' is not accessible in this context because it is 'Friend'.

i checked the whole code ..wondering if i am missing something ... nothing!

searched -->

1: maybe it is different a littel... i don't know

2:i am not sure if it is the same issue .. and it looks complicated to me..

note: i copy (Convert) that from C#.net project and it is working just fine in (C#.net)....!

Thanks in advance.

+2  A: 

Your ReportsOfficesEntities class says Partial Class ReportsOfficesEntities not Public Class ReportsOfficesEntities. Is that the reason?

Fadrian Sudaman
oh..i didn't notice that... i'll check
jjj
@Fadrian... it was working fine in C#.net...the same code..!!
jjj
Partial Class-->Partial Public Class.Friend is the default access modifer for any class and a Friend class cannot be used outside the assembly.
Explogit
Class default access is also internal in C#, which will caused the above code not to compile as well unless they are in the same assemblies
Fadrian Sudaman
@Fadrian ... i am telling you it is the same code , the same root paths in C# but it is working..!!
jjj
Well, it can't be the same code, the C# compiler can't compile VB.NET code. The missing `Public` keyword is the obvious source of the error message.
Hans Passant