DEV Community

Wallism
Wallism

Posted on

dotnet swagger tofile : Could not load file or assembly System.Runtime

When running this command:
dotnet swagger tofile --output "valid-path" "valid-dll" v1

I was getting this error:

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
File name: 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

The target dll was .net 5.0 but because I have .net 6.0 installed, my system was using that sdk by default. To use the correct sdk when running dotnet cli, this SO answer has a clear explanation. Basically you add a new global.json file at a folder level that makes sense (e.g. project or solution root folder).

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay