'Get' accessor of property '<propertyname>' is not accessible

A statement attempts to retrieve the value of a property when it does not have access to the property's Get procedure.

If the Get Statement is marked with a more restrictive access level than its Property Statement, an attempt to read the property value could fail in the following cases:

  • The Get statement is marked Private (Visual Basic) and the calling code is outside the class or structure in which the property is defined.

  • The Get statement is marked Protected (Visual Basic) and the calling code is not in the class or structure in which the property is defined, nor in a derived class.

  • The Get statement is marked Friend (Visual Basic) and the calling code is not in the same assembly in which the property is defined.

Error ID: BC31103

To correct this error

  • If you have control of the source code defining the property, consider declaring the Get procedure with the same access level as the property itself.

  • If you do not have control of the source code defining the property, or you must restrict the Get procedure access level more than the property itself, try to move the statement that reads the property value to a region of code that has better access to the property.

See Also

Tasks

How to: Declare a Property with Mixed Access Levels

Concepts

Property Procedures