✅ Predefined type 'System.ValueTuple2' is not defined or imported

I made sure to install the Systems.ValueTuple NuGet Package and I keep getting this error. I went to make sure the target framework is correct and I don't have that option so I did the latest windows build. Here is a copy of the code
25 Replies
TypicalSoldier
TypicalSoldierOP2y ago
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409 namespace Methods { /// <summary> /// An empty page that can be used on its own or navigated to within a Frame. /// </summary> public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } private void calculateClick(object sender, RoutedEventArgs e) { int calculatedValue = 0; try { int leftHandSide = System.Int32.Parse(lhsOperand.Text); int rightHandSide = System.Int32.Parse(rhsOperand.Text); if (addition.IsChecked.HasValue && addition.IsChecked.Value) { calculatedValue = addValues(leftHandSide, rightHandSide); showResult(calculatedValue); } else if (subtraction.IsChecked.HasValue && subtraction.IsChecked.Value) { calculatedValue = subtractValues(leftHandSide, rightHandSide); showResult(calculatedValue); } else if (multiplication.IsChecked.HasValue && multiplication.IsChecked.Value) { calculatedValue = multiplyValues(leftHandSide, rightHandSide); showResult(calculatedValue); } else if (division.IsChecked.HasValue && division.IsChecked.Value) { int division, remainder; (division, remainder) = divide(leftHandSide, rightHandSide); result.Text = $" remainder "; } } catch (Exception caught) { expression.Text = ""; result.Text = caught.Message; } } private int addValues(int leftHandSide, int rightHandSide) { expression.Text = $"{leftHandSide} + {rightHandSide}"; return leftHandSide + rightHandSide; } private int subtractValues(int leftHandSide, int rightHandSide) { expression.Text = $"{leftHandSide} - {rightHandSide}"; return leftHandSide - rightHandSide; } private int multiplyValues(int leftHandSide, int rightHandSide) { expression.Text = $"{leftHandSide} * {rightHandSide}"; return leftHandSide * rightHandSide; } private (int, int) divide(int leftHandSide, int rightHandSide) { expression.Text = $" / "; int division = leftHandSide / rightHandSide; int remainder = leftHandSide % rightHandSide; return (division, remainder); } private void showResult(int answer) => result.Text = answer.ToString(); } }
Angius
Angius2y ago
System.ValueTuple is not a nuget Unless you're maybe using some ancient-ass version of C# for some godforsaken reason that didn't have valuetuples yet
TypicalSoldier
TypicalSoldierOP2y ago
if you search it up in the nuget manager it pops up and you can install it...with or without it, i still get this godforsaken error Predefined type 'System.ValueTuple`2' is not defined or imported for whatever the fuck reason
Angius
Angius2y ago
What's your .NET and C# version?
TypicalSoldier
TypicalSoldierOP2y ago
is the lines generating the error
Angius
Angius2y ago
Some ancient versions of C# might get ValueTuple support from that nuget, but not necessarily the short (a, b) syntax So, what's the version you're using?
TypicalSoldier
TypicalSoldierOP2y ago
idk how to check it but i just downloaded the lastest .net version 7.0.4
Angius
Angius2y ago
Open the csproj file
TypicalSoldier
TypicalSoldierOP2y ago
its open
Angius
Angius2y ago
And? <TargetFramework> and <LangVersion> are what you're looking for
TypicalSoldier
TypicalSoldierOP2y ago
it says those aren't found in my solution
Angius
Angius2y ago
They're in the csproj file Open it in a text editor
TypicalSoldier
TypicalSoldierOP2y ago
TypicalSoldier
TypicalSoldierOP2y ago
TypicalSoldier
TypicalSoldierOP2y ago
it says it isnt there either
Angius
Angius2y ago
That's an old csproj format For some reason you made this project using some ancient version of .NET Like, ancient ancient version, because even the ancient and dead .NET Framework started using the new format eventually
TypicalSoldier
TypicalSoldierOP2y ago
it's for a current university class...the book it has us reading is based on VS 2017 what the fuckkk
Angius
Angius2y ago
Ah, well, university explains using 1999 technologies Your professor probably hasn't learned anything new since 2001, and it was a recipe for granola bars In any case, instead of using the cool new value tuples, you can use the old Tuple<int, int> as the return type And use Tuple.Create() to make it Alternatively, use new versions of .NET $newproject
MODiX
MODiX2y ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
TypicalSoldier
TypicalSoldierOP2y ago
i figured when it asks the target version i want to upgrade to and i select windows 11 it should update it to the newest release
Angius
Angius2y ago
"Windows 11" is neither the version of the framework nor the version of the language It's the version of the Windows SDK your app will use
TypicalSoldier
TypicalSoldierOP2y ago
is there any reliable way to quickly update these projects to the newest .net framework?
Angius
Angius2y ago
There's the upgrade assistant you can try
TypicalSoldier
TypicalSoldierOP2y ago
i was able to fix the problem entirely by updating the .net.universalwindowsplatform package in nuget... thanks for all your help!!! $close
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server