jjj*_*jjj 3 .net c# vb.net accessibility
一个有趣的问题......我无法理解它......
让我先告诉你我有什么:
'D:\ReportsOfficesSystem\ReportsOfficesBLL\BaseController.vb'
^ ^ ^
solution project a vb class file
Run Code Online (Sandbox Code Playgroud)
和
'D:\ReportsOfficesSystem\ReportsOfficesDAL\ReportsOfficesEntities.vb'
^ ^ ^
the same solution an other project a vb class file
Run Code Online (Sandbox Code Playgroud)
在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
Run Code Online (Sandbox Code Playgroud)
在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
Run Code Online (Sandbox Code Playgroud)
当然,我添加了两个项目的参考资料......
中的错误BaseController.vb:
'ReportsOfficesDAL.ReportsOfficesModel.ReportsOfficesEntities' is not accessible in this context because it is 'Friend'.
Run Code Online (Sandbox Code Playgroud)
我检查了整个代码......想知道我是否遗漏了什么......什么都没有!
搜索-->
1:也许有点不同……我不知道
2:我不确定这是否是同一个问题..对我来说看起来很复杂..
注意:我从 C#.net 项目复制(转换)它,它在 (C#.net) 中工作得很好......!
提前致谢。
你的ReportsOfficesEntities班级说Partial Class ReportsOfficesEntities不是Public Class ReportsOfficesEntities。是这个原因吗?
| 归档时间: |
|
| 查看次数: |
7599 次 |
| 最近记录: |