Reference to type '(, )' claims it is defined in 'mscorlib', but it could not be found

Viewed 3094

I am getting this compile time error in my wpf project suddenly in VS 2019, which was working fine till now.

Error:Severity Code Description Project File Line Suppression State Error CS7069 Reference to type '(, )' claims it is defined in 'mscorlib', but it could not be found

Same project if i run in VS 2017 it works fine, i tried many things like clearing temp files, re clone my code base but nothing helped me. I do not get which type it is claiming from the error as '(,)'.

Could someone please assist me what is this issue and why am i getting only in VS2019 and not in VS2017 and any way to resolve this. I have spent lots of my time already any help would be appreciated.

3 Answers

Install System.ValueTuple package into your project. That's what is likely causing errors for you.

In addition to AngryHacker's suggestion, make sure that if you have multiple projects, that their .NET versions all match up.

In my case, I had a project built with .NET Framework 4.7.2 where I defined a method that returned a ValueTuple and then I called that method from another project built with .NET Framework 4.6.1. After upgrading the project's .NET version from 4.6.1 to 4.7.2 and relaunching VisualStudio, I was able to build the code.

The reason you are getting this in VS2019 when you were not in VS2017 is that a newer version of System.ValueTuple is being included in your project during the build.

You can find where this is by building with diagnostic logging and looking for System.ValueTuple in the logs. I had this issue and found this:

Copying file from "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ValueTuple.dll"

With your build logs you should be able to find where to fix it in your project but as @angryhacker mentioned in his answer one way is to specifically include the System.ValueTuple that your projects expect in the references of your project, or to install the Nuget package in your project.

@sean-killian describes another way that the versions can disagree. The compile error is cryptic, but you should find that on the line of code referenced the System.ValueTuple type is being used in your code, or in the signature of the function that you are calling.

Related