CallerLineNumberAttribute' exists in both 'System.Runtime' and 'mscorlib'

Mr Edge 221 Reputation points

Running Visual Studio 2022 + all updates.

I have an old version of a Class Library running on .Net 4.7.

Im attempting to upgrade it to the new SDK style so

I first run the command

dotnet tool install --global Project2015To2017.Migrate2019.Tool


dotnet migrate-2019 wizard pathToProject

It asks to modernize the app and all questions that pop up i select Y.

I attempt to rebuild the project and get a package error (Microsft.Bcl) so search for this under the NuGet package options and install again. The next error that im presented with is

The type 'CallerLineNumberAttribute' exists in both 'System.Runtime, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' and 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'

Ive tried making different amendments to the .csproj file (removing <PackageReference Include="System.Runtime" Version="4.3.1" /> changing other values) but no matter what i try the above error remains.

What could i do to stop that error and build the project? If you require more info please advise and i can post any configs i have.

Microsoft Technologies based on the .NET software framework.
3,331 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,567 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,184 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 54,626 Reputation points

    if you mix <4.5 and 4.6+ projects then you need the bcl nuget package. you will probably also need binding mappings.

    your best bet is to first update all the projects to 4.6+. and upgrade the nuget packages in the projects to a version that support net46 or netstandard20.

    if this is a solo 4.7 library project, then the nuget packages are the issue. you should upgrade them first and remove the bcl requirement.

    i'd also convert the project to netstandard 2.0 if the nuget packages allow, so you do not need runtime entires in the project file.

    0 comments No comments