由于其保护级别,无法访问该类

编程入门 行业动态 更新时间:2024-10-26 23:37:15
本文介绍了由于其保护级别,无法访问该类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在两个解决方案中都使用了一个项目IBSampleApp,并且它们的类在这两个类中均遇到以下编译器错误。

I have one project IBSampleApp used in two solutions and it’s classes suffer the following compiler error in both.

由于受到保护而无法访问级别

inaccessible due to it’s protection level

执行解决方案中IB执行项目的IBClient.cs错误:

Error in IBClient.cs of IB Execution project in Execution solution:

IBSampleApp项目中的TickPriceMessage类:

TickPriceMessage class in IBSampleApp project:

已将InternalsVisibleTo属性添加到IBSampleApp项目的AssemblyInfo.cs中(由@JamesFaix推荐):

Added InternalsVisibleTo property to AssemblyInfo.cs of IBSampleApp project (recommended by @JamesFaix):

问题仍然存在。如何使TickPriceMessage类可用于两个解决方案?

The problem persistes still. How to make TickPriceMessage class available to both solutions?

推荐答案

您在内部类上有一个公共构造函数。在缺少任何访问修饰符的情况下,c#默认为对类型的限制最大,对于像您这样的课程,它是内部的

You have a public constructor on an internal class. With lack of any access modifier, c# defaults to the most restricted for the type which is internal for a class like yours.

// this is an "internal" class class TickPriceMessage { ... }

更多推荐

由于其保护级别,无法访问该类

本文发布于:2023-11-26 19:57:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634973.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:于其   无法访问   级别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!