C# "error CS1503: argument cannot convert from X to Y" in CI
A method call passes an argument of a type the compiler cannot convert to the parameter type. CS1503 names the argument position and both types, so the mismatch is precise.
What this error means
dotnet build fails with "error CS1503: Argument 1: cannot convert from 'string' to 'int'" at the call site, often after an API version change.
Order.cs(18,28): error CS1503: Argument 1: cannot convert from 'string' to 'int'Common causes
A genuine type mismatch at the call site
The caller passes the wrong type, or an overload that accepted it was removed.
A dependency version changed the signature
CI resolved a different package version whose method signature differs from the one the code was written against.
How to fix it
Pass the expected type
- Read the argument number and the two types in the error.
- Convert or supply a value of the parameter type at that call.
- Re-build to confirm the call type-checks.
// expected int, not string
Process(int.Parse(rawId));Pin the dependency the code targets
If a package upgrade changed the signature, pin the version whose API your code uses, or update the call to the new API.
<PackageReference Include="Some.Lib" Version="3.2.0" />How to prevent it
- Lock dependency versions so method signatures stay stable in CI.
- Build locally against the same resolved versions CI uses.
- Review API changes when bumping packages.