IEC global variable from C# program

As InOut is not avaiblable for c# program i try to read and write global variable defined in IEC61131-3.
As the HMI attribut for C# variable or port appear to not be working (Variable with hmi attribute of the githut miscattribute example don’t appear in ehmi editor )
My goal is to reset flag which is set in the hmi after c# program handle it.
Actually i found use the following method to achieve this.
Using Eclr.Pcos.Resource.GetGlobalRootType i can access to global variable. . Is there a better solution?
Whats the purpose PcosDomain Method I dont find any explaination on help file.

Type t = Eclr.Pcos.Resource.GetGlobalRootType();
System.Reflection.FieldInfo myboolinfo= t.GetField("myboolean");
 Boolean bb = (Boolean)myboolinfo.GetValue(null);
  Eclr.Log.Info("myboolean={0}",bb);
  if(bb == true){
     //Trigger some action then reset value;
     myboolinfo.SetValue(null, false);

regards Alexandre

Just an idea:
If you change you C# code from „Program“ to „Function Block“ (FB) you can use VAR_IN_OUT. Thus the call of the FB can forward the variable to be reset into the FB.