一个有趣的问题...我无法理解..
让我先给你看看我有什么:
'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'.
我检查了整个代码..想知道我是否遗漏了什么......什么都没有!
已搜索 -->
1:也许有点不同......我不知道
2:我不确定这是否是同一个问题..对我来说它看起来很复杂..
注意:我从 C#.net 项目复制(转换)它,它在 (C#.net) 中工作得很好......!
提前致谢。
最佳答案
您的 ReportsOfficesEntities
类说的是 Partial Class ReportsOfficesEntities
而不是 Public Class ReportsOfficesEntities
。是这个原因吗?
关于c# - 无法访问 VB 类文件...... friend 的事,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2350778/