2010-02-28 1 views
2

смешная проблема ... я не могу понять ..VB Class Файл не доступен ... Друг вещь

позвольте мне показать вам, что у меня есть первая:

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

и

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

в 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 

в 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 

и, конечно, я добавил ссылки для обоих проектов ...

ошибка в BaseController.vb:

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

я проверил весь код ..wondering если г что-то не хватает ... ничего!

искали ->

1: может быть, она отличается Littel ... я не знаю

2: я не уверен, если это тот же вопрос .. и это кажется сложным для меня ..

примечание: i копировать (конвертировать), что из проекта C# .net, и он работает просто отлично (C# .net) ....!

Заранее спасибо.

ответ

4

Ваш ReportsOfficesEntities класс говорит Partial Class ReportsOfficesEntities не Public Class ReportsOfficesEntities. Это причина?

+0

oh..i не заметил, что ... я проверю – jjj

+0

@Fadrian ... он работал нормально в C# .net ... тот же код .. !! – jjj

+0

Частичный класс -> Частичный открытый класс. Друг - это модификатор доступа по умолчанию для любого класса, а класс Friend не может использоваться вне сборки. – Explogit