Skip to content
This repository was archived by the owner on May 15, 2024. It is now read-only.
This repository was archived by the owner on May 15, 2024. It is now read-only.

System.ArgumentException: Handle must be valid. Parameter name: instance when calling SecureStorage.GetAsync #380

@harindaka

Description

@harindaka

Description

Steps to Reproduce

Random. I have a code which makes 2 calls to SecureStorage.GetAsync in the ViewModel each time a Xamarin Forms Page loads. I'm able to crash the app by repeatedly navigating to and back from this page (repeated calls to SecureStorage.GetAsync). Most of the time it works as expected until the exception occurs

Expected Behavior

No errors

Actual Behavior

Throws the following exception at random and crashes.
Handle must be valid. Parameter name: instance

At the call to

await SecureStorage.GetAsync

{System.ArgumentException: Handle must be valid.
Parameter name: instance
  at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00009] in <7802aa64ad574c33adca332a3fa9706a>:0 
  at Android.Runtime.JNIEnv.CallObjectMethod (System.IntPtr jobject, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in <263adecfa58f4c449f1ff56156d886fd>:0 
  at Android.Content.ISharedPreferencesInvoker.GetString (System.String key, System.String defValue) [0x0006c] in <263adecfa58f4c449f1ff56156d886fd>:0 
  at Xamarin.Essentials.SecureStorage.PlatformGetAsync (System.String key) [0x0001a] in <e3b2ff3137884401ace22dbf653e6c03>:0 
  at Xamarin.Essentials.SecureStorage.GetAsync (System.String key) [0x00013] in <e3b2ff3137884401ace22dbf653e6c03>:0 
  at SolutionAccelerators.Utilities.Encryption.EncryptionUtility+<ReadRijndael256KeyAsync>d__12.MoveNext () [0x0000f] in /source/SolutionAccelerators/Utilities/Encryption/EncryptionUtility.cs:173 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 
  at SolutionAccelerators.Utilities.Encryption.EncryptionUtility+<DecryptRijndael256Async>d__10.MoveNext () [0x000b9] in /source/SolutionAccelerators/Utilities/Encryption/EncryptionUtility.cs:137 }

Basic Information

  • Version with issue: 0.7.0.17-preview
  • Last known good version: ?
  • IDE: Visual Studio for Mac
  • Platform Target Frameworks: Android
    • iOS: N/A
    • Android: 8.1
    • UWP: N/A
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices: Moto Z Play

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions