Skip to content

Assembly.GetFile should throw an explicit exception for memory-loaded assemblies #40154

Closed

Description

@vitek-karas

Assembly.GetFile and Assembly.GetFiles currently calls Module.FullyQualifiedName and then returns a FileStream over that path. For assemblies loaded from memory (or any other assembly not loaded directly from a file) this will try to load a file like "C:\currentdirectory\<Unknown>" because Module.FullyQualifiedName returns constant <Unknown> for memory-loaded assemblies. Opening such file will typically fail with IOException.

It would be much cleaner to explicitly handle this case in Assembly.GetFile/Assembly.GetFiles and throw some more specific exception. In theory it's possible that the file <Unknown> will actually exist in which case the API would return basically a random stream of data.

Activity

  1. added
    area-AssemblyLoader-coreclr
    untriaged
    on Jul 30, 2020
  2. removed
    untriaged
    on Aug 3, 2020
  3. added this to the 5.0.0 milestone on Aug 3, 2020
  4. added a commit that references this issue on Aug 9, 2020
    11a8902
  5. added a commit that references this issue on Aug 15, 2020
    c73371d
  6. ghost locked as resolved and limited conversation to collaborators on Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-AssemblyLoader-coreclr

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions