Open
Description
Description
If you are running an application in an architecture, say arm64
and you are referencing an assembly for a different architecture, say x64
- the error message that appears is misleading:
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'src, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Problem is, the file is definitely there. What is happening is an architecture mismatch - not the file not being present on the disk.
Reproduction Steps
- Create a project for an architecture that is not compatible with your current computer. In my case I have a M3 MacBook, so x86 and x64 would not work:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<PlatformTarget>x86</PlatformTarget>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
- Run the project:
dotnet run
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'src, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
- Yet, the assembly is there:
ls bin/Debug/net8.0/ | grep src (master)test
src
src.deps.json
src.dll
src.pdb
src.runtimeconfig.json
Expected behavior
The message should clearly say that there is an architecture mismatch for the assembly
Metadata
Metadata
Assignees
Type
Projects
Status
No status