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

IsolatedStorageFile.GetUserStoreForApplication throws "Initialization failed." on net6.0-android #52332

Closed
mattleibow opened this issue May 5, 2021 · 4 comments · Fixed by #56534
Assignees
Milestone

Comments

@mattleibow
Copy link
Member

Description

Call IsolatedStorageFile.GetUserStoreForApplication() and observe an exception:

 android.runtime.JavaProxyThrowable: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
  ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
  ---> System.TypeInitializationException: The type initializer for 'Microsoft.Maui.Controls.UriImageSource' threw an exception.
  ---> System.IO.IsolatedStorage.IsolatedStorageException: Initialization failed.
    at System.IO.IsolatedStorage.Helper.GetDefaultIdentityAndHash(Object& identity, String& hash, Char separator)
    at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
    at System.IO.IsolatedStorage.IsolatedStorageFile..ctor(IsolatedStorageScope scope)
    at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope)
    at System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()

Configuration

This is running with net6.0-android. Works with MonoAndroid and on some other platforms.

Regression?

This works on non-net6.0 Android.

Other information

Original issue: dotnet/android#5705

@dotnet-issue-labeler dotnet-issue-labeler bot added area-System.IO untriaged New issue has not been triaged by the area owner labels May 5, 2021
@ghost
Copy link

ghost commented May 5, 2021

Tagging subscribers to this area: @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Call IsolatedStorageFile.GetUserStoreForApplication() and observe an exception:

 android.runtime.JavaProxyThrowable: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
  ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
  ---> System.TypeInitializationException: The type initializer for 'Microsoft.Maui.Controls.UriImageSource' threw an exception.
  ---> System.IO.IsolatedStorage.IsolatedStorageException: Initialization failed.
    at System.IO.IsolatedStorage.Helper.GetDefaultIdentityAndHash(Object& identity, String& hash, Char separator)
    at System.IO.IsolatedStorage.IsolatedStorage.InitStore(IsolatedStorageScope scope, Type domainEvidenceType, Type assemblyEvidenceType)
    at System.IO.IsolatedStorage.IsolatedStorageFile..ctor(IsolatedStorageScope scope)
    at System.IO.IsolatedStorage.IsolatedStorageFile.GetStore(IsolatedStorageScope scope)
    at System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()

Configuration

This is running with net6.0-android. Works with MonoAndroid and on some other platforms.

Regression?

This works on non-net6.0 Android.

Other information

Original issue: dotnet/android#5705

Author: mattleibow
Assignees: -
Labels:

area-System.IO, untriaged

Milestone: -

@akoeplinger
Copy link
Member

The issue here is that in an Android application there's no assembly with a Main() method so Assembly.GetEntryAssembly returns null right now which IsolatedStorage doesn't like:

// Note that it is possible that there won't be an EntryAssembly, which is something the .NET Framework doesn't
// have to deal with and shouldn't be likely on .NET Core due to a single AppDomain. Without Evidence
// to pull from we'd have to dig into the use case to try and find a reasonable solution should we
// run into this in the wild.
Assembly? assembly = Assembly.GetEntryAssembly();
if (assembly == null)
throw new IsolatedStorageException(SR.IsolatedStorage_Init);

@akoeplinger akoeplinger added this to the 6.0.0 milestone May 5, 2021
@marek-safar marek-safar removed the untriaged New issue has not been triaged by the area owner label May 5, 2021
@adamsitnik
Copy link
Member

@akoeplinger should we move it to 7.0?

@steveisok
Copy link
Member

Unless there's a solution to a null GetEntryAssembly, I think we should consider PNSE for IsolatedStorage

akoeplinger added a commit to akoeplinger/runtime that referenced this issue Jul 29, 2021
Android doesn't set an entry assembly so we need to handle that case.

Fixes dotnet#52332
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 29, 2021
akoeplinger added a commit that referenced this issue Jul 29, 2021
Android doesn't set an entry assembly so we need to handle that case.

Fixes #52332
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 29, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants