c# - 无法访问 VB 类文件...... friend 的事

标签 c# .net vb.net accessibility

一个有趣的问题...我无法理解..

让我先给你看看我有什么:

'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/

相关文章:

c# - EWS 搜索过滤器查找发件人域 C#

.net - XSD : Could not find schema information for the element 的 XML 验证

vb.net - Console.Write在Win Forms应用程序中不起作用

c# - 何时使用或不使用 Lambda 表达式

vb.net - 将焦点设置到文本框控件

c# - Sitecore 子项目排序问题

c# - 如何对某些 StyleCop 规则进行异常(exception)处理?

c# - 带有 C# 的索尼相机 API

c# - 在 StackExchange.Redis 中通过键模式获取值

c# - 从源代码动态创建已编译的 .NET exe?