Xamarin.forms: Application.Quit throws an error

Created on 6 Aug 2018  ·  6Comments  ·  Source: xamarin/Xamarin.Forms

Hi,

I am trying just a simple:

Application.Quit()

but getting:

Error CS0120: An object reference is required for the non-static field, method, or property 'Application.Quit()' (CS0120)

needs-info ❓ needs-repro ❔

All 6 comments

Can you please attach a sample project that shows what you're trying to do? Thank you!

Please see the attached

ApplicationQuit.zip

Try Application.Current.Quit(). Application.Current is the instance. If you have further questions such as this, you may want to try posting them on the forums (https://forums.xamarin.com/categories/xamarin-forms). Thank you!

I only tried Application.Quit because it was mentioned here:

https://docs.microsoft.com/en-us/dotnet/api/xamarin.forms.application.quit?view=xamarin-forms

regarding the Application.Current.Quit() it does nothing when you call it as you can see in this attached project.
ApplicationQuit.zip

Ah, that's good feedback. We should update the documentation to be more clear here. This feature was added for desktop platforms only ( see #1126). It doesn't apply to mobile platforms. Sorry for the confusion.

thanks Samantha 👍

Was this page helpful?
0 / 5 - 0 ratings