Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing initialization exceptions in Xamarin client #358

Open
sschaub opened this issue Aug 6, 2021 · 1 comment
Open

Preventing initialization exceptions in Xamarin client #358

sschaub opened this issue Aug 6, 2021 · 1 comment
Labels

Comments

@sschaub
Copy link

sschaub commented Aug 6, 2021

Issue Description

Special configuration is required to prevent the following exception from being thrown during ParseClient initialization on Xamarin platform:

Value cannot be null. Parameter name: element

The issue is caused by an assumption encoded into the HostManifestData.Inferred property (Assembly.GetEntryAssembly() is non-null) that is not true on Xamarin. This has been noted in various issues such as #344.

Suggestions

Two suggestions come to mind to improve the situation:

  1. Modify HostManifestData.Inferred so that it populates the Version, Name, and ShortVersion properties with some kind of reasonable default value (empty strings?) if Assembly.GetEntryAssembly() is missing instead of throwing an exception.
  2. Modify HostManifestData.Inferred to throw an exception with a more meaningful error message to help Xamarin users realize that special configuration is needed.
@sschaub sschaub changed the title Preventing exceptions in Xamarin client Preventing initialization exceptions in Xamarin client Aug 6, 2021
@drharris
Copy link

For those running into this, you can get past this issue by initializing using something like the following (the key is to not let it perform lazy initialization on anything that relies on a MetadataController - note the same metadata controller below has been passed into the ServiceHub). There may be other areas you'll need to embed this depending on how your configuration is.

var m = new MetadataMutator
{
      EnvironmentData = new EnvironmentData { TimeZone = TimeZoneInfo.Local.StandardName },
      HostManifestData = new HostManifestData { Name = "Test", Identifier = "TestApp", ShortVersion = "1.0.0.0", Version = "1.0.0.0" }
};
ParseClient client = new ParseClient(new ServerConnectionData
{
       ApplicationID = "APP_ID",
       ServerURI = "SERVER_URI",
       Key = "APP_KEY"
},
new LateInitializedMutableServiceHub { MetadataController=m },
m
);
client.Publicize();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants