Class inaccessible due to its protection level [closed]

半世苍凉 提交于 2019-12-11 17:19:18

问题


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.



来源:https://stackoverflow.com/questions/55568182/class-inaccessible-due-to-its-protection-level

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!