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

Fix SingleFile regression in IsolatedStorageFile #42306

Closed
wants to merge 1 commit into from
Closed
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 @@ -51,23 +51,25 @@ internal static void GetDefaultIdentityAndHash(out object identity, out string h
Assembly? assembly = Assembly.GetEntryAssembly();

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

AssemblyName assemblyName = assembly.GetName();
#pragma warning disable SYSLIB0012
Uri codeBase = new Uri(assembly.CodeBase!);
#pragma warning restore SYSLIB0012

hash = IdentityHelper.GetNormalizedStrongNameHash(assemblyName)!;

if (hash != null)
{
hash = "StrongName" + separator + hash;
identity = assemblyName;
}
else
{
hash = "Url" + separator + IdentityHelper.GetNormalizedUriHash(codeBase);
identity = codeBase;
// in case of SingleFile, Location.Length returns 0.
string fileName = assembly.Location.Length == 0 ? assemblyName.Name! : Path.GetFileName(assembly.Location);
Uri assemblyPath = new Uri(Path.Combine(AppContext.BaseDirectory, fileName));
hash = "Url" + separator + IdentityHelper.GetNormalizedUriHash(assemblyPath);
identity = assemblyPath;
}
}

Expand Down