Class inaccessible due to its protection level [cl

2019-08-28 19:40发布

问题:

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:

TickPriceMessage class in IBSampleApp project:

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

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

回答1:

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
{
   ...
}


回答2:

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