@@ -46,35 +46,37 @@ internal static void GetDefaultIdentityAndHash(out object identity, out string h
46
46
// by pulling directly from EntryAssembly.
47
47
//
48
48
// Note that it is possible that there won't be an EntryAssembly, which is something the .NET Framework doesn't
49
- // have to deal with and shouldn't be likely on .NET Core due to a single AppDomain. Without Evidence
50
- // to pull from we'd have to dig into the use case to try and find a reasonable solution should we
51
- // run into this in the wild.
49
+ // have to deal with and isn't likely on .NET Core due to a single AppDomain. The exception is Android which
50
+ // doesn't set an EntryAssembly.
52
51
53
52
Assembly ? assembly = Assembly . GetEntryAssembly ( ) ;
53
+ string ? location = null ;
54
54
55
- if ( assembly == null )
56
- throw new IsolatedStorageException ( SR . IsolatedStorage_Init ) ;
57
-
58
- AssemblyName assemblyName = assembly . GetName ( ) ;
59
-
60
- hash = IdentityHelper . GetNormalizedStrongNameHash ( assemblyName ) ! ;
61
- if ( hash != null )
55
+ if ( assembly != null )
62
56
{
63
- hash = "StrongName" + separator + hash ;
64
- identity = assemblyName ;
65
- }
66
- else
67
- {
68
- string ? location = assembly . Location ;
69
- // In case of SingleFile deployment, Assembly.Location is empty.
70
- if ( location == string . Empty )
71
- location = Environment . ProcessPath ;
72
- if ( string . IsNullOrEmpty ( location ) )
73
- throw new IsolatedStorageException ( SR . IsolatedStorage_Init ) ;
74
- Uri locationUri = new Uri ( location ) ;
75
- hash = "Url" + separator + IdentityHelper . GetNormalizedUriHash ( locationUri ) ;
76
- identity = locationUri ;
57
+ AssemblyName assemblyName = assembly . GetName ( ) ;
58
+
59
+ hash = IdentityHelper . GetNormalizedStrongNameHash ( assemblyName ) ! ;
60
+ if ( hash != null )
61
+ {
62
+ hash = "StrongName" + separator + hash ;
63
+ identity = assemblyName ;
64
+ return ;
65
+ }
66
+ else
67
+ {
68
+ location = assembly . Location ;
69
+ }
77
70
}
71
+
72
+ // In case of SingleFile deployment, Assembly.Location is empty. On Android there is no entry assembly.
73
+ if ( string . IsNullOrEmpty ( location ) )
74
+ location = Environment . ProcessPath ;
75
+ if ( string . IsNullOrEmpty ( location ) )
76
+ throw new IsolatedStorageException ( SR . IsolatedStorage_Init ) ;
77
+ Uri locationUri = new Uri ( location ) ;
78
+ hash = "Url" + separator + IdentityHelper . GetNormalizedUriHash ( locationUri ) ;
79
+ identity = locationUri ;
78
80
}
79
81
80
82
internal static string GetRandomDirectory ( string rootDirectory , IsolatedStorageScope scope )
0 commit comments