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

Sisk S'jet shared this bug 5 years ago
Outdated

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

Replies (3)

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

photo
1

This is not fixed

photo
1

Sure? I use it in the SmartRotor mod without issues.

photo
1

Well I hooked the event for both IMyMotorStator and IMyPistonBase and received the error / CTD when placing a small grid regular rotor.

photo
Leave a Comment
 
Attach a file