Home > Backend Development > C++ > Why Am I Getting a 'Predefined type 'System.ValueTuple' is not defined or imported' Error in Visual Studio?

Why Am I Getting a 'Predefined type 'System.ValueTuple' is not defined or imported' Error in Visual Studio?

Mary-Kate Olsen
Release: 2024-12-28 20:38:14
Original
671 people have browsed it

Why Am I Getting a

ValueTuple Error in Visual Studio 15 Preview 3

The introduction of the new tuple feature in Visual Studio 15 Preview 3 sparked excitement among developers. However, some users encountered the "Predefined type 'System.ValueTuple´2´ is not defined or imported" error when compiling code.

This error indicates that the "System.ValueTuple" type is not recognized by the compiler. While the blog post suggests that this feature is enabled by default, it is not the case for certain frameworks and versions.

Solution

For .NET 4.6.2 or lower, .NET Core 1.x, and .NET Standard 1.x, the "System.ValueTuple" NuGet package must be installed:

Install-Package "System.ValueTuple"
Copy after login

Alternatively, in Visual Studio 2017, a package reference can be added:

<PackageReference Include="System.ValueTuple" Version="4.4.0" />
Copy after login

.NET Frameworks and Versions

It is important to note that different frameworks and versions include this type by default:

  • .NET Framework 4.7 and higher
  • .NET Core 2.0 and higher
  • .NET Standard 2.0 and higher

By using the NuGet package or package reference, users can access the "System.ValueTuple" type in lower versions of these frameworks, allowing them to utilize the tuple feature.

The above is the detailed content of Why Am I Getting a 'Predefined type 'System.ValueTuple' is not defined or imported' Error in Visual Studio?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template