xamarin / Xamarin.Auth

Xamarin.Auth
Apache License 2.0
541 stars 351 forks source link

Exception on latest versions of Xamarin.iOS, Xcode, etc #378

Closed Janglinator closed 5 years ago

Janglinator commented 5 years ago

Xamarin.Auth Issue

Version

Steps to reproduce

Simply attempt to use the latest version of Xamarin.Auth on the latest versions of Xcode, VS4Mac, Xamarin.iOS, etc.

This exception occurs regardless of whether the app was previously installed on the iOS device or not.

I've attempted to completely uninstall and reinstall Xamarin.Auth from both my common project, as well as my iOS project.

Platform:

Expected behaviour

Preferably not throw an exception.

Actual behaviour

I'm receiving the following exception when attempting to FindAccountsForService:

"Search/Find FindAccountsForServiceAsync Object reference not set to an instance of an object"

"  at Xamarin.Auth.KeyChainAccountStore.FindAccountsForServiceAsync (System.String serviceId) [0x0007f] in <85539ee049364f3e8d64880a4a42b589>:0 \n  at Xamarin.Auth.KeyChainAccountStore.FindAccountsForService (System.String serviceId) [0x00000] in <85539ee049364f3e8d64880a4a42b589>:0 \n  at MetaFarmsSow.Model.Utilities.CryptographicUtility.RetrieveKey (System.String propertyName, System.Int32 length) [0x00011] in /Users/jangles/TFS/SowApp/V4/Model/Utilities/CryptographicUtility.cs:31 "

Inner exception:

"Object reference not set to an instance of an object"

"  at Xamarin.Auth.KeyChainAccountStore+<>c.<.cctor>b__12_2 () [0x00042] in <85539ee049364f3e8d64880a4a42b589>:0 \n  at System.Lazy`1[T].ViaFactory (System.Threading.LazyThreadSafetyMode mode) [0x0001c] in <50aa8c853ba54c99b7836ba4b45a5828>:0 \n--- End of stack trace from previous location where exception was thrown ---\n\n  at System.LazyHelper.ThrowException () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.8.0.0/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Lazy.cs:97 \n  at System.Lazy`1[T].CreateValue () [0x0007e] in <50aa8c853ba54c99b7836ba4b45a5828>:0 \n  at System.Lazy`1[T].get_Value () [0x0000a] in <50aa8c853ba54c99b7836ba4b45a5828>:0 \n  at Xamarin.Auth.KeyChainAccountStore.FindAccountsForServiceAsync (System.String serviceId) [0x00030] in <85539ee049364f3e8d64880a4a42b589>:0 "

My invocation:

        public static byte[] RetrieveKey(string propertyName, int length)
        {
            Account account = null;

            try
            {
                account = AccountStore.Create().FindAccountsForService(nameof(PersistanceUtility)).FirstOrDefault((Account arg) => arg.Username == propertyName);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }

            ...
        }
sillerjp commented 5 years ago

Hi @Janglinator , please check this out: https://github.com/xamarin/Xamarin.Auth/issues/370/

Janglinator commented 5 years ago

Thank you! I searched around for an open issue, didn't think to look in closed issues.

To be fair, issues shouldn't be closed until a release fixes the issue 😉

kleindev commented 5 years ago

Any idea on when the fix will be released? Would be beneficial for me as well

Janglinator commented 5 years ago

^ Ditto.

Currently attempting to build the project myself, but running into:

Error occurred when compiling build script: /Users/jangles/Downloads/Xamarin.Auth-master/build.cake(2051,55): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
moljac commented 5 years ago

@kleindev

Any idea on when the fix will be released?

i'm working on this when I have time - when I'm not on other projects. Sorry.

mlyrstad commented 5 years ago

We too are struggling with this issue. We can't migrate to Xamarin.Essentials SecureStore because of this crash.

kleindev commented 5 years ago

@mlyrstad best I can find so far is to try out these manually built dlls: https://github.com/xamarin/Xamarin.Auth/issues/370#issuecomment-489140679

Disclaimer - I haven't done myself yet. I'm planning to use the dlls and also migrate to Xamarin Essentials (need a working Xamarin Auth for migration path to work)

moljac commented 5 years ago

1.7.0-alpha01 released.

kleindev commented 5 years ago

Can confirm that this works for me - I'm using Visual Studio 2019. Thank you

moljac commented 5 years ago

@kleindev Thanks for reporting. I will create release 1.7.0.0 and publish ASAP (today or tomorow).

After that I would like to ask you to close this issue please.

moljac commented 5 years ago

duplicate of https://github.com/xamarin/Xamarin.Auth/issues/370

closing

thomashoef commented 5 years ago

@moljac 1.7.0-alpha01 released. with fix for this issue What branch is the fix on? Is it in a particular commit? Thanks!