Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,37 @@ internal static void GetDefaultIdentityAndHash(out object identity, out string h
// by pulling directly from EntryAssembly.
//
// 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.
// have to deal with and isn't likely on .NET Core due to a single AppDomain. The exception is Android which
// doesn't set an EntryAssembly.

Assembly? assembly = Assembly.GetEntryAssembly();
string? location = null;

if (assembly == null)
throw new IsolatedStorageException(SR.IsolatedStorage_Init);

AssemblyName assemblyName = assembly.GetName();

hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!;
if (hash != null)
if (assembly != null)
{
hash = "StrongName" + separator + hash;
identity = assemblyName;
}
else
{
string? location = assembly.Location;
// In case of SingleFile deployment, Assembly.Location is empty.
if (location == string.Empty)
location = Environment.ProcessPath;
if (string.IsNullOrEmpty(location))
throw new IsolatedStorageException(SR.IsolatedStorage_Init);
Uri locationUri = new Uri(location);
hash = "Url" + separator + IdentityHelper.GetNormalizedUriHash(locationUri);
identity = locationUri;
AssemblyName assemblyName = assembly.GetName();

hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!;
if (hash != null)
{
hash = "StrongName" + separator + hash;
identity = assemblyName;
return;
}
else
{
location = assembly.Location;
}
}

// In case of SingleFile deployment, Assembly.Location is empty. On Android there is no entry assembly.
if (string.IsNullOrEmpty(location))
location = Environment.ProcessPath;
if (string.IsNullOrEmpty(location))
throw new IsolatedStorageException(SR.IsolatedStorage_Init);
Uri locationUri = new Uri(location);
hash = "Url" + separator + IdentityHelper.GetNormalizedUriHash(locationUri);
identity = locationUri;
}

internal static string GetRandomDirectory(string rootDirectory, IsolatedStorageScope scope)
Expand Down