Class inaccessible due to its protection level [cl

2019-08-28 19:06发布

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

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

enter image description here

TickPriceMessage class in IBSampleApp project:

enter image description here

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

enter image description here

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

2条回答
2楼-- · 2019-08-28 19:39

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
{
   ...
}
查看更多
孤傲高冷的网名
3楼-- · 2019-08-28 19:51

You should declare TickPriceMessage class as public, it is internal by default.

查看更多
登录 后发表回答