I ran into this issue today and wanted to document it.
void Start() {
ObjectiveCRuntime.Initialize();
var x = NSApplication.NSApplicationLaunchRemoteNotificationKey;
}
Running that I get MethodNotFoundException.
What seems to happen is Start() is JIT compiled, NSApplicationLaunchRemoteNotificationKey is resolved, which resolves ObjectiveCRuntime.GetExtern() which internally uses GetInstanceInternal. The latter is an internal method which hasn't been registered yet because the bridge hasn't been bootstrapped because ObjectiveCRuntime.Initialize() hasn't actually executed yet. More specifically, the static constructor for ObjectiveCRuntime hasn't executed yet because Start() is still being compiled.
Moving the constant extern to a separate method works around it.
void Start() {
ObjectiveCRuntime.Initialize();
CheckConstant();
}
void CheckConstant() {
var x = NSApplication.NSApplicationLaunchRemoteNotificationKey;
}
I ran into this issue today and wanted to document it.
Running that I get
MethodNotFoundException.What seems to happen is
Start()is JIT compiled,NSApplicationLaunchRemoteNotificationKeyis resolved, which resolvesObjectiveCRuntime.GetExtern()which internally usesGetInstanceInternal. The latter is an internal method which hasn't been registered yet because the bridge hasn't been bootstrapped becauseObjectiveCRuntime.Initialize()hasn't actually executed yet. More specifically, the static constructor forObjectiveCRuntimehasn't executed yet becauseStart()is still being compiled.Moving the constant extern to a separate method works around it.