Skip to content

Unable to load assemblies using SDK 7.0.202 but worked on SDK 7.0.201 #83526

Closed
@reduckted

Description

@reduckted

Description

When compiled using .NET SDK 7.0.202, code that uses Assembly.Load(AssemblyName) fails to load assemblies that exists in the application directory.

Here's how you can reproduce the bug.

  1. Make sure you have .NET SDK 7.0.201 and 7.0.202 installed.
  2. Clone https://github.com/reduckted/LoadAssemblyBug
  3. Open PowerShell and run run.ps1.

The application is quite simple. It finds all .dll files in the current working directory, gets the assembly name from each file, then uses Assembly.Load() to load that assembly.

Use the run.ps1 script to reproduce the bug. It will first publish the application using SDK 7.0.201, then run the application. This will succeed and you will see it log the name of each assembly that it loads. Next it will publish the application using SDK 7.0.202, then run the application. This will fail for the vast majority of assemblies.

Here's a snippet of the output when using 7.0.201:

Loading assembly: LoadAssemblyBug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Loading assembly: Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Loading assembly: Microsoft.AspNetCore.Authentication.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Loading assembly: Microsoft.AspNetCore.Authentication.Cookies, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Loading assembly: Microsoft.AspNetCore.Authentication.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Loading assembly: Microsoft.AspNetCore.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

And here's a snippet of the output when using 7.0.202:

Loading assembly: LoadAssemblyBug, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Loading assembly: Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Could not load file or assembly 'Microsoft.AspNetCore.Antiforgery, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=AMD64'. The system cannot find the file specified.
Loading assembly: Microsoft.AspNetCore.Authentication.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Could not load file or assembly 'Microsoft.AspNetCore.Authentication.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=AMD64'. The system cannot find the file specified.
Loading assembly: Microsoft.AspNetCore.Authentication.Cookies, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Could not load file or assembly 'Microsoft.AspNetCore.Authentication.Cookies, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=AMD64'. The system cannot find the file specified.
Loading assembly: Microsoft.AspNetCore.Authentication.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Could not load file or assembly 'Microsoft.AspNetCore.Authentication.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=AMD64'. The system cannot find the file specified.
Loading assembly: Microsoft.AspNetCore.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Could not load file or assembly 'Microsoft.AspNetCore.Authentication, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=AMD64'. The system cannot find the file specified.

Configuration

  • .NET version: .NET SDK 7.0.202, self-contained published application.
  • OS: Windows 10
  • Architecture: x64

I've tried using Microsoft.NET.Sdk.Web and Microsoft.NET.Sdk, and both exhibit the same bug.

I have not tried using a different OS.

Regression?

Yes. This works flawlessly when compiled with .NET SDK 7.0.201.

Related to dotnet/core#8285

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions