Skip to content

FileNotFoundException warning on application startup. #181

Open

Description

@kostekk88

Hi

I'm getting warnings on application startup when loading assemblies through .AddExtCore(...).

warn: ExtCore.WebApplication[0]
System.IO.FileNotFoundException: Could not load file or assembly 'Portable.BouncyCastle ....

It originates here :
`private void GetAssembliesFromDependencyContext(List assemblies)

{
  this.logger.LogInformation("Discovering and loading assemblies from DependencyContext");

  foreach (CompilationLibrary compilationLibrary in DependencyContext.Default.CompileLibraries)
  {
    if (this.IsCandidateCompilationLibrary(compilationLibrary))
    {
      Assembly assembly = null;

      try
      {
        assembly = AssemblyLoadContext.Default.LoadFromAssemblyName(new AssemblyName(compilationLibrary.Name));

        if (!assemblies.Any(a => string.Equals(a.FullName, assembly.FullName, StringComparison.OrdinalIgnoreCase)))
        {
          assemblies.Add(assembly);
          this.logger.LogInformation("Assembly '{0}' is discovered and loaded", assembly.FullName);
        }
      }

      catch (Exception e)
      {
        this.logger.LogWarning("Error loading assembly '{0}'", compilationLibrary.Name);
        this.logger.LogWarning(e.ToString());
      }
    }
  }
}`

It looks like the list DependencyContext.Default.CompileLibraries contains Assembly information and ExtCore is using compilationLibrary.Name as assembly name, but actually, as far as I can tell it's the name of the Package and not the assembly name. When I find my package on the CompileLibrarie list it will contain in the Assemblies collection the correct dll name, but because the above code uses the Name property it cannot find it.

It's more of a question than a bug report as I am no expert on assembly loading and reflection. I don't know if its a bug in ExtCore or something wrong with the nugget package (manifest?).

Repro steps:

  • New .net core WebApp
  • add ExtCore.WebApplication
  • add services.AddExtCore() in startup
  • add Portable.BouncyCastle (just an example of a package where assembly name is not the same as dll name)
  • start the app

Activity

  1. DmitrySikorsky commented on Nov 22, 2020

    @DmitrySikorsky
    Member

    Hi @kostekk88, thank you. Yes, I know about this issue. I think I need to look at it again, because it has been done long time ago.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions