parse-community / Parse-SDK-dotNET

Parse SDK for .NET, Xamarin, Unity.
http://parseplatform.org
Apache License 2.0
322 stars 260 forks source link

[v2.0.0-develop-1][Xamarin] - FindAsync causes ArgumentNullException - Solution found #345

Closed AlexeyStarkov closed 3 years ago

AlexeyStarkov commented 3 years ago

[v2.0.0-develop-1][Xamarin.Forms][Android]

Hello. I've found a bug trying to retrieve data from a database using Android (Xamarin.Forms). I've also managed to detect a reason. 1) It looks in this way: capture 2) An exception is caused in HostManifestData.Inferred property because Assembly.GetEntryAssembly() returns "null" capture1 I've also found a possible reason why it happens: https://xamarin.github.io/bugzilla-archives/21/21097/bug.html

Solution: Assembly.GetEntryAssembly() calls should be replaced to Assembly.GetExecutingAssembly() in HostManifestData.Inferred property getter of Parse/Infrastructure/HostManifestData.cs class.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

TobiasPott commented 3 years ago

Sorry for the late response on this and I'm glad that you've found a solution already. Your solution includes changing the source code, which might be fine in your case, but may not in others.

The intended way to solve this issue would be providing a custom-configured instance of HostManifestData as described in https://github.com/parse-community/Parse-SDK-dotNET#use-in-unity-client. This allow you to defined that SDK's part's behaviour to either use fixed values or use a different method to determine the inferred values. This should be done when creating your ParseClient instance in code.

The need to do so, depends on the platform you are targeting with your project. iOS and Android are two of those and unfortunately I'm unaware of a list to determine on which platforms what methods Assembly.Get[xxx]Assembly() return proper values and which do not. Thus I would recommend to use the above described way to provide a custom configuration for your project and platform.

Kind regards Tobias