RobotStudio event

Problem writing I/O signals with SDK

Hello,

I am trying to write I/O signals in a virtual controller with a C# app, but when I set/reset the value of one of them, it is displayed the error:

"The operation is not allowed in current operation mode.For example, a remote user may not be allowed to perform the operation in manual mode."

I tried to fix it by changing the access value of signal in RobotStudio (to ALL), but the problem remains the same. Writing Rapiddata (robtarget, etc.) I have no problems...

My code (the I/O writing part) is as shown below:

if (_controller.OperatingMode == ControllerOperatingMode.Auto)
                    {
                        using (Mastership m = Mastership.Request(_controller.Rapid))
                        {
                            Signal sig = _controller.IOSystem.GetSignal(item.Text);
                            DigitalSignal digitalSig = (DigitalSignal)sig;
                            int val = digitalSig.Get();
                            if (val == 1)
                            {
                                digitalSig.Set();
                            }
                            else
                            {
                                digitalSig.Reset();
                            }
                        }
                    }

I know there are some issues regarding the same thing, but none of them have been resolved as far as I know. I would appreciate any help or suggestion.

Thank you in advance.

Alex