Forum Xamarin.Forms

Xamarin.Forms 2.0 issues

I just recompiled my project with Xamarin.Forms 2.0 and found Application.Current.SavePropertiesAsync is not working as expected in "Release" mode.

I used the following code to save the login email

Application.Current.Properties ["LoginEmail"] = loginInfo.Email;
await Application.Current.SavePropertiesAsync ();

and then load it when the app starts.
if (Application.Current.Properties.ContainsKey ("LoginEmail")) {
c_email.Text = (string)Application.Current.Properties ["LoginEmail"];
}

But now, I cannot load the saved email any more. The strange thing is, it still works in debug mode. Can anyone help me out?. It will be a big headache for me to rollout an update.

Thanks.

Best Answer

Answers

  • karbokarbo DEMember

    Have a look here:
    https://forums.xamarin.com/discussion/55993/application-current-properties-dont-work-in-xamarin-2-0

    I now use the Xamarin.Plugin Settings, works fine!

  • VincentwxVincentwx CAMember ✭✭

    @karbo, thanks for the suggestion. I can use that plug in for a new app, but cannot use it on the current app for an update.

  • EZHartEZHart USXamarin Team Xamurai

    @Vincentwx Which platforms are you experiencing this problem on? Does it consistently work in Debug mode on all platforms? Does it consistently fail in Release mode on all platforms?

  • VincentwxVincentwx CAMember ✭✭

    Hi E.Z.

    My project is only on Android for now. I don't know if it's the same issue or not on other platforms. My environment is the latest Xamarin Studio on window with Xamarin.Forms 2.0. The device is Samsung Galaxy 3. The problem is consistent as I described in my environment.

    Thanks for looking into it.

  • VincentwxVincentwx CAMember ✭✭

    Here are more details about my project (Please let me know if you need a specific setting in my project)

    Xamarin.Forms 2.0.0.6484.

    Xamarin Studio
    Version 5.10 (build 871)
    Installation UUID: 746773da-aa82-4843-8c4a-d8310009ec85
    Runtime:
    Microsoft .NET 4.0.30319.42000
    GTK+ 2.24.23 (MS-Windows theme)
    GTK# 2.12.30

    Xamarin.Profiler
    Not Installed

    Xamarin.Android
    Version: 6.0.0 (Indie Edition)
    Android SDK: C:\Users\vincentw.AMPM\AppData\Local\Android\android-sdk
    Supported Android versions:
    2.3 (API level 10)
    4.0.3 (API level 15)
    4.4 (API level 19)
    5.0 (API level 21)
    5.1 (API level 22)
    6.0 (API level 23)

    SDK Tools Version: 24.4.1

    SDK Platform Tools Version: 23.0.1

    SDK Build Tools Version: 23

    Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_71
    java version "1.7.0_71"
    Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
    Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)

    Xamarin Android Player
    Version: 0.4.4
    Location: C:\Program Files\Xamarin Android Player\DeviceManager.exe

    Build Information
    Release ID: 510000871
    Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
    Build date: 2015-11-12 07:16:34-05
    Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
    Build lane: monodevelop-windows-cycle6

    Operating System
    Windows 10.0.10240.0 (64-bit)

    My Project Settings:

    Please check attached screenshot

  • EZHartEZHart USXamarin Team Xamurai

    @Vincentwx Do you have linking enabled for your project?

  • VincentwxVincentwx CAMember ✭✭

    @EZHart I am not sure which option you mean, can you show me a screenshot where to check it?

  • EZHartEZHart USXamarin Team Xamurai

    @Vincentwx In your Android project properties, under Build -> Android Build, select the Linker tab. What is 'Linker behavior' set to?

  • VincentwxVincentwx CAMember ✭✭

    I have the same setting as yours. Here is the screenshot attached. However. please be aware I am using xamarin studio on Windows, not on MAC

  • EZHartEZHart USXamarin Team Xamurai

    @Vincentwx Can you try changing your setting to "Don't Link" and see if you still have the issue with the properties in Release mode?

    I'm not suggesting that as a real workaround, I'm just trying to eliminate some possibilities.

  • VincentwxVincentwx CAMember ✭✭

    @EZHart. I changed to "Don't Link" and it fixed the problem. Now I can save and load the settings. Can I expect a fix in the next release?

    Thanks.

  • EZHartEZHart USXamarin Team Xamurai

    @Vincentwx I can't speak to the timeline for a fix just yet, but this definitely gets us closer. Thank you for the update!

  • VincentwxVincentwx CAMember ✭✭

    @EZHart Thanks for looking into it. I don't want to rush to use the customer linking. I will wait for a fix.

  • DebajyotiMahanta.3248DebajyotiMahanta.3248 USMember, University

    any update on this?

  • CarlosForeroCarlosForero USUniversity ✭✭

    I have the same problem in "Release" mode. That is fixed using "Don't link".

    A drawback is that the package creation fails using "Don't link" and LLVM, therefore is not possible to use LLVM in the release package.

  • CarlosForeroCarlosForero USUniversity ✭✭

    @EZHart the custom linker configuration has worked for me:

    <?xml version="1.0" encoding="utf-8" ?>
    <linker>
      <assembly fullname="System.Runtime.Serialization">
        <namespace fullname="System.Runtime.Serialization" />
      </assembly>
    </linker>
    
  • VincentwxVincentwx CAMember ✭✭

    @EZHart How close is it that this problem will be fixed in the next release? I am still waiting for it.

  • Frustrating. I get the issue even in Debug mode (on Android). I'm moving all my Application.Current.Properties read/writes to use SqlLite instead.

  • VincentwxVincentwx CAMember ✭✭

    @EZHart I just did a test on the latest stable release, this bug is still not fixed. In the pre-release version, there is no mention about any fix either. Is there any chance this bug is going to be fixed at all?

  • AdrianKnightAdrianKnight USMember ✭✭✭✭

    @EZHart Would the linker tag with System.Runtime.Serialization solve this debugging problem? https://forums.xamarin.com/discussion/59391/vs2015-debugger-freezes-on-initial-run#latest I can't figure out why this dll is causing me trouble on Android.

  • VincentwxVincentwx CAMember ✭✭

    The custom linker configuration workaround from @EZHart in this thread worked for me.

  • EZHartEZHart USXamarin Team Xamurai

    @Vincentwx Have you updated to Xamarin.Android 6.0.1? There are multiple bugs related to the Application Properties, and there was a fix in that version which may address your issue.

    If the issue is still occurring with that version, does the Android console display any messages with the category "Xamarin.Forms PropertyStore"?

  • VincentwxVincentwx CAMember ✭✭

    @EZHart I have it, Version: 6.0.1.10 (Indie Edition), on my machine(Windows). When I did the test on Feb 11, I made sure everything about Xamarin was up to date. But I don't know if this version was released before that. I still prefer not using the Customer Linker Configuration, but I moved on with it anyway. Thanks

Sign In or Register to comment.