c# - Accessing CoreWindow from a windows phone 8.1 runtime component -
i'm trying access corewindow windows phone 8.1 c++ runtime component. component needs react events fired corewindow. have following code.
iasyncaction^ myclass::registercorewindowvisibilitychanged() { return coreapplication::mainview->corewindow->dispatcher->runasync(coredispatcherpriority::high, ref new dispatchedhandler( [this] { auto eventhandler = ref new typedeventhandler<corewindow^, visibilitychangedeventargs^>(this, &myclass::oncorewindowvisibilitychanged); window::current->corewindow->visibilitychanged += eventhandler; } )); }
this works fine, when application using component universal app, fails in silverlight application access violation exception.
0xc0000005: access violation reading location 0x00000000.
apparently windows::current
returns null in silverlight app. there way works in silverlight windows store app?
that object available in universal application (as documented).
you need either conditionalize compile or consider switching universal app both desktop , phone.
Comments
Post a Comment