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

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

If the Set Statement (Visual Basic) is marked with a more restrictive access level than its Property Statement, an attempt to set the property value could fail in the following cases:

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

  • The Set 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 Set statement is marked Friend (Visual Basic) and the calling code is not in the same assembly in which the property is defined.

Error ID: BC31102

To correct this error

  • If you have control of the source code defining the property, consider declaring the Set 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 Set procedure access level more than the property itself, try to move the statement that sets 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 (Visual Basic)

Concepts

Property Procedures (Visual Basic)