我有一个项目IBSampleApp在两个解决方案中使用,它的类在两者中都遇到以下编译器错误。
由于其保护级别无法访问
执行解决方案中IB执行项目的IBClient.cs出错:
IBSampleApp项目中的TickPriceMessage类:
将InternalsVisibleTo属性添加到IBSampleApp项目的AssemblyInfo.cs(由@JamesFaix推荐):
问题仍然存在。如何使TickPriceMessage类可用于这两种解决方案?
您在内部类上有一个公共构造函数。由于缺少任何访问修饰符,c#默认为the most restricted for the type,这对于像你这样的类来说是internal
。
// this is an "internal" class
class TickPriceMessage
{
...
}
您应该将TickPriceMessage类声明为public
,默认情况下它是internal
。