[ModApi] Exception thrown on IMyMotorStator.AttachedEntityChanged event handler register

Sisk S'jet shared this bug 12 months ago
Considered

When we try to register an event handler for IMyMotorStator.AttachedEntityChanged, an exception is thrown:

Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.

The same exception is thrown on IMyLandingGear.LockModeChanged


Test code:

using Sandbox.Common.ObjectBuilders;
using Sandbox.ModAPI;
using VRage.Game.Components;
using VRage.ModAPI;
using VRage.ObjectBuilders;

namespace Test {
    [MyEntityComponentDescriptor(typeof(MyObjectBuilder_MotorStator), false)]
    public class StatorLogic : MyGameLogicComponent {
        private IMyMotorStator _stator;

        public override void Close() {
            _stator.AttachedEntityChanged -= OnAttachedEntityChanged;
        }

        public override void Init(MyObjectBuilder_EntityBase objectBuilder) {
            _stator = Entity as IMyMotorStator;
            NeedsUpdate = MyEntityUpdateEnum.BEFORE_NEXT_FRAME;
        }

        public override void UpdateOnceBeforeFrame() {
            _stator.AttachedEntityChanged += OnAttachedEntityChanged;
        }

        private void OnAttachedEntityChanged(IMyMotorBase obj) { }
    }
}

Best Answer
photo

It is already fixed at least in version 1.190.1. I didn't check it before.

Maybe mark it as solved :D

Comments (2)

photo
1

Hello, Engineer!


Thank you for your feedback! Your topic has been added between considered issues.


Please keep voting for the issue as it will help us to identify the most serious bugs.


We really appreciate your patience.


Kind Regards


Keen Software House: QA Department

photo
1

It is already fixed at least in version 1.190.1. I didn't check it before.

Maybe mark it as solved :D