Windows 8 Unhandled exception at 0x59E273B3

Monkey Forums/Monkey Programming/Windows 8 Unhandled exception at 0x59E273B3

therevills(Posted 2013) [#1]
I get the following error when hitting Escape after running the below code:

Unhandled exception at 0x59E273B3 (msvcr110d.dll) in MonkeyGame.exe:
An invalid parameter was passed to a function that considers invalid parameters fatal.


Strict

Import mojo

Function Main:Int()
	New Game
	Return 0
End

Class Game Extends App
	Method OnCreate:Int()
		SetUpdateRate(60)
		Return 0
	End

	Method OnUpdate:Int()
		If KeyHit(KEY_ESCAPE)
			OnBack()
		End
		Return 0
	End
	
	Method OnRender:Int()
		Cls
		DrawText "HELLO WIN8", 100, 100
		Return 0
	End
	
	Method OnBack:Int()
		Error ""
		Return 0
	End
End



Xaron(Posted 2013) [#2]
Is there a reason why you call Error "" in OnBack() instead of using AppExit (or is it ExitApp)?


Amon(Posted 2013) [#3]
Is there a reason why you call Error "" in OnBack() instead of using AppExit (or is it ExitApp)?


I've tried it myself with each command. It still crashes.


MikeHart(Posted 2013) [#4]
And in which monkey version ?


therevills(Posted 2013) [#5]
Sorry should have put 71c.

Error "" was the old standard way to quit, but it shouldn't be crashing like this.

And EndApp just wraps Error "".


MikeHart(Posted 2013) [#6]
I noticed that you call OnBack yourself. I would be surprised if that would be the right order, would rather expect Monkey to react on some windows event and then call OnBack itself.


marksibly(Posted 2013) [#7]
On Win 8 (not actually sure what this means for 'tablet' apps as I don't think they have a back button) you can ONLY call Error "" (or preferably EndApp) in response to the *OS* calling your OnBack method - calling it yourself doesn't count.

Yes, this sucks big time, but believe me, I wasted a considerable amount of time trying to find a (sane; usable) work around for this before admitting defeat.

This is obviously gonna come up again and again, but the docs to EndApp (and OnBack) cover this pretty well I think:


Important! On Windows Phone 8, The only time you can end an application is when the OS calls your app's OnClose or OnBack method. To end an application, use EndApp.



The operative phrase here is 'when the OS calls'...

Not sure what the app should do if you try and EndApp at the wrong time - I could generate a more meaningful runtime error I guess, but I doubt it'll end this confusion.


therevills(Posted 2013) [#8]
Thanks Mark...

So how would I get the application to quit if the user hits the Escape key or an on-screen Quit button?


marksibly(Posted 2013) [#9]
> So how would I get the application to quit if the user hits the Escape key or an on-screen Quit button?

To the best of my knowledge, you can't - win8 is designed to not allow this.


marksibly(Posted 2013) [#10]
More here...

http://msdn.microsoft.com/en-us/library/windows/apps/hh464925.aspx

In particular:


You can't include any UI in your app to enable the user to close your app, or it won't pass the Store certification process.




therevills(Posted 2013) [#11]
Going by that then I suggest that Error "" and EndApp does not do anything at all for Win8.


Amon(Posted 2013) [#12]
I have tested this by downloading 5-8 free apps from the Windows Store and pressing escape within each app does nothing.

The only way to close the app is when you either go back to the Windows RT interface, right click it and select close or go to the desktop then move your mouse to the top left of your screen and when a preview of the app pops up on screen right click it and select close.

Testing this with my app it works the same. I have no idea what MS were thinking when designing things this way.

But yes, escape doing nothing on Win8 will suffice as all other apps seem to play the same way.


therevills(Posted 2013) [#13]
I have no idea what MS were thinking when designing things this way.

Kind of copying iOS (and Android to some degree)... they all seem to think that applications should never quit these days.

Oh and on Windows 8 to quit an app you go to the top of the screen and drag down to the bottom of the screen with the mouse pressed.

I've changed Diddy to stop try to quit for Win8 - sorry about the mess up Amon when I tested my change it worked under Blend (for VS2012) which confused me...


Redbeer(Posted 2013) [#14]
I'm using Diddy as a framework, the one I got from the most recent version of Diddy on the google site, and I have the demo version of Monkey installed.

On the Macs (OS 10.8.4) that I run at work, with the exact same code, using the exact same versions of Monkey and Diddy, I get an error that keeps the program from running. Essentially it goes into the Diddy functions.monkey file and highlights EndApp() saying it is not found?

How do I fix this?
I'd mess around with the code, but I don't have write access to the install, so this is something that I need a fix that I can push to our IT guys who believe we are all stupid (and most of us are admittedly), and thus won't let us write a single bit to the hard drive of our local machines.

Any help would be greatly appreciated.


Gerry Quinn(Posted 2013) [#15]
So annoying! Don't they understand that users WANT to be able to end their apps?

[Edit: well, at least Windows does provide an easy-to-access termination option, so maybe it's okay that they don't let you make one in code.]