Skip to content

Mono's RuntimeAssembly.GetName calls CodeBase #54835

@eerhardt

Description

@eerhardt

CodeBase is marked as RequiresAssemblyFiles, which means that it can throw an exception if the application is published as a single-file application.

public override AssemblyName GetName(bool copiedName)
{
return AssemblyName.Create(_mono_assembly, CodeBase);
}

We should decide what to do here for Mono. In CoreCLR, we don't call CodeBase directly, but instead we call the underlying GetCodeBase() method, which returns null when running in a single-file application:

// If the assembly is copied before it is loaded, the codebase will be set to the
// actual file loaded if copiedName is true. If it is false, then the original code base
// is returned.
public override AssemblyName GetName(bool copiedName)
{
string? codeBase = GetCodeBase();
var an = new AssemblyName(GetSimpleName(),
GetPublicKey(),
null, // public key token
GetVersion(),
GetLocale(),
GetHashAlgorithm(),
AssemblyVersionCompatibility.SameMachine,
codeBase,
GetFlags() | AssemblyNameFlags.PublicKey);

Maybe we should do the same?

cc @akoeplinger @steveisok

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions