Skip to content
Latchkey

C# "CS1503: Argument N: cannot convert from A to B" in CI

CS1503 means you passed an argument the method does not accept - the Nth argument's type cannot convert to the parameter type. It often appears after a package upgrade changed a signature, or when an overload you expected does not exist.

What this error means

Build fails with CS1503 naming the argument position and the from/to types. Deterministic for the source + reference versions.

dotnet
Handler.cs(31,38): error CS1503: Argument 2: cannot convert from 'int' to
'System.Threading.CancellationToken'

Common causes

The argument type does not match the parameter

The value passed is a different type than the method expects, and no implicit conversion exists.

A signature changed across a package version

An upgrade reordered or retyped parameters, so existing call sites pass the wrong type.

How to fix it

Pass the correct argument type

  1. Check the method signature for the expected parameter type and order.
  2. Convert or supply the right value (e.g. a CancellationToken instead of an int).
  3. Rebuild.
.cs
await repo.SaveAsync(entity, cancellationToken);

Align with the upgraded API

  1. Read release notes for the changed signature.
  2. Update call sites, or pin the previous package version if needed.
  3. Rebuild.

How to prevent it

  • Build after package upgrades to catch signature changes early.
  • Pin package versions with a lock file so CI matches local.
  • Use named arguments for clarity on multi-parameter calls.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →