Exception error when forcing an application exit

Hi.

I added a trial mode to our game and I am having some problems forcing an exit when the trial mode has expired. Originally I was getting an exception in the UnityPlayer.dll in some Memory Profiler call when I called App.Current.Exit() during the OnLaunched method in the XAML project. Here the game would launch, I would determine the trial mode has expired, and if the user chooses not to buy the full version, the game would exit. I fixed this occurrence by delaying the call to [appCallbacks = new AppCallbacks(false);] until after I finished with the license boot up testing.

So now I still have a problem where the trial period expires while the user is still playing the game. Again, I prompt them to see if they would like to buy the full version. If they decline, I attempt to close the application, again by calling [App.Current.Exit()]. As mentioned, this causes an exception in the call [UnityPlayer.dll!MemoryProfiler.UnlinkHeader]

I will continue to debug this, but my main question is, is there some proper method of shutting down a Unity Win8 App Store application that I am overlooking?

Thanks in advance.

Sean

Why aren’t you using Application.Quit ()?

I think you’ll fail WACK, if you’ll try to exit the application, like it said here - CoreApplication Class (Windows.ApplicationModel.Core) - Windows UWP applications | Microsoft Learn

Exiting application programmatically should be used only for testing purposes.

I remember that, but once I started researching the trial mode I came across this:

•Trial license expires while the app is running

If the trial expires while your app is running, your app can:
◦Do nothing.
◦Display a message to your customer.
◦Close.
◦Prompt your customer to buy the app.

The best practice is to display a message with a prompt for buying the app, and if the customer buys it, continue with all features enabled. If the user decides not to buy the app, close it or remind them to buy the app at regular intervals.

It might a problem in the docs… In any case, it’s your call :slight_smile:

Do you mean Application.Current.Exit() ? I don’t see an Application.Quit()

http://docs.unity3d.com/Documentation/ScriptReference/Application.Quit.html

So any reason why Unity crashes when I try manually exiting the program then? Is there some extra step I need to do?

Ahh, sorry, you are talking about quitting from within Unity? Ok, that’s an idea. I have been trying to quit from the XAML code.

This doesn’t appear to work. It seems to cause this exception when I signal the Unity code from the XAML code to call Application.Exit:

A first chance exception of type ‘System.NullReferenceException’ occurred in UnityEngineProxy.DLL

I am curious how Win8 normally shuts down Unity when the application goes dormant for more than the typical 5 seconds or so.

Are you signalling to call Application.Exit or Application.Quit? There is no such thing as Application.Exit in Unity.

Sorry, I meant Application.Quit

Decided to just spam the user with the popups instead of quitting. Forcing an exit seems way too volatile anyways.