Error when access Register's value with RegLong using PCDK C#

  • Hi all,


    I am trying to access and manipulate FANUC V9.30P/08 controller's registers using PCDK (version V9.30(Rev.B)) in C#. Please help me understanding why the following code does not work:


    The outputs (belows) indicates that "RegLong" does not exist in "FRCVar" object.

    Code
    Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
      HResult=0x80131500
      Message='System.__ComObject' does not contain a definition for 'RegLong'
      Source=<Cannot evaluate the exception source>
      StackTrace:
    <Cannot evaluate the exception stack trace>




    However, I have followed these threads and this seeing that the similar syntax work. Can anyone please help?

  • I think I found the solution already. Since layer.Value returns back a dynamic object that does not support RegLong property, I had to transform it back to FRCRegNumeric first.


    The solution is:

    C#
    {
      ...
                FRCVars robot_registers = myrobot.RegNumerics;
    
                FRCVar layer = robot_registers[6];
                FRCRegNumeric layer_value = layer.Value;
                Console.WriteLine(layer_value.RegLong);
      ...
    }

Advertising from our partners