Skip to content

File-based apps: low-repro 'FileNotFoundException: Could not load file or assembly <blah>' #53732

@KostasVsNT

Description

@KostasVsNT

Describe the bug

As part of some app/script, we execute dotnet.exe run MyScript.cs -- <params here>. This sometimes fails with 'FileNotFoundException: Could not load file or assembly '.

To Reproduce

dotnet.exe run MyScript.cs -- <params here>

Sorry, that's all I have :(, see below.

Exceptions (if any)

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'SomeDependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'SomeDependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Program.

$(String[] args)
at Program.$(String[] args)
at Program.(String[] args)
...
Exit code: -532462766.

(^ the last bit is from our script, I believe)

Further technical details

details of dotnet --info

NET SDK: Version: 10.0.100 Commit: b0f34d51fc Workload version: 10.0.100-manifests.4c0ca8ba MSBuild version: 18.0.2+b0f34d51f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: D:.......\Tools\DotNetSDK\dotnet-sdk-10.0.100-win-x64\sdk\10.0.100\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.0
Architecture: x64
Commit: b0f34d51fc

.NET SDKs installed:
10.0.100 [D:..........\Tools\DotNetSDK\dotnet-sdk-10.0.100-win-x64\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 10.0.0 [D:.................\Tools\DotNetSDK\dotnet-sdk-10.0.100-win-x64\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 10.0.0 [D:.................\Tools\DotNetSDK\dotnet-sdk-10.0.100-win-x64\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 10.0.0 [D:...................\Tools\DotNetSDK\dotnet-sdk-10.0.100-win-x64\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: N/A

It's a very rare repro. Out of an estimated 100 executions/day in my company, for the last 3 months, we've had about 6-7 incidents.

I believe that when this issue is triggered, it becomes a 100% repro issue on that machine.

The dependent dlls that it (apparently) can't find were always on the disk in the expected locations, in all the cases I looked at. One was in the nuget cache on C, and the other was in the bin directory of a dependent csproj. Maybe the issue is that a downstream dependency was actually missing somehow, and I regret not checking with Depends.exe, at least. I'll do this next time.

The solution I found was to delete the runfile cache %TEMP%\dotnet\runfile. That always allows it to work again. After this, we've not had repeats on the same machine so far, AFAIK.

There was a weak correlation with the C drive running out of disk space, in two of those cases at least, but I don't know if that makes sense... Each script takes about 250 MB in the runfile cache, so not massive. I tried to repro the problem this way (by filling my C drive to various degrees), but I failed to.

I went through the release notes of the .NET SDK, from 10.0.100 to the latest as I write this (10.0.201), and I don't see a related fix. Let me know if I should try updating anyway.

Any thoughts? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-run-fileItems related to the "dotnet run <file>" effortuntriagedRequest triage from a team member

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions