2

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Globe
  • 280
  • 2
  • 15

2 Answers2

5

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
{
   ...
}
Jamiec
  • 133,658
  • 13
  • 134
  • 193
1

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

Jaime
  • 5,770
  • 4
  • 23
  • 50
  • Isn't that what OP's `InternalsVisibleTo` is for? – ProgrammingLlama Apr 08 '19 at 07:29
  • 1
    @John I wouldn't recommend that approach, unless you want some very-constrained visibility scenario. The most usual way is to declare the class as public. – Jaime Apr 08 '19 at 07:35
  • Failed to get InternalsVisibleTo property work. Turned all classes public which resolves compiler error problem – Globe Apr 08 '19 at 21:11