[Closed] dotNet.addEventHandler cannot access struct members?
Yup. Agreed. In a perfect world they shouldn鈥檛. This is a specific use of an explicit global variable that is only there to work around what I think is either a bug or a design limitation.
In mxsdotnet.cpp the dotNet_add_event_handler_cf() function checks to see if the currentStruct has been set. If there is a currentStruct it binds the event to a StructMethod function, which I assume (in the absence of actually witnessing it happen) it needs to do in order to call a function bound to an instance of a struct.
I tried a bunch different variations to try and get it to hit following line of code without any luck:
vl.fn = new StructMethod(currentStruct, vl.fn);
Yeah, my workaround breaks a cardinal rule, but it breaks it consistently, and I make sure it happens in a documented manner.