由于其保护等级而无法进入的类别[关闭]

问题描述 投票:-1回答:2

我有一个项目IBSampleApp在两个解决方案中使用,它的类在两者中都遇到以下编译器错误。

由于其保护级别无法访问

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

enter image description here

IBSampleApp项目中的TickPriceMessage类:

enter image description here

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

enter image description here

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

c# class project access solution
2个回答
4
投票

您在内部类上有一个公共构造函数。由于缺少任何访问修饰符,c#默认为the most restricted for the type,这对于像你这样的类来说是internal

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

1
投票

您应该将TickPriceMessage类声明为public,默认情况下它是internal

© www.soinside.com 2019 - 2024. All rights reserved.