Solution
This error can be caused if you are working with DIO modules and the I/O direction is not correctly defined to match the operation you are doing with the shared variable (read or write). You can check this by going to the Module Properties:

After setting the correct direction and clicking Ok, remember to do a deploy on the target.