-3

I am building an application in Visual Studio 2017 intended to be run on a Windows XP machine, but being able to use C# 7.0 tuple literals would be an ideal component to my solution.

I thought I could just add two nuget packages, Microsoft.Net.Compilers and System.ValueType, to enable my executable to use the syntax like (string foo, string bar) but I'm getting a syntax error, CS8179 C# Predefined type is not defined or imported. Visual Studio's ctrl + . feature tries to get me to nuget-install System.ValueType, but it's already installed in the project. Another option is use local version 4.4.0, but selecting that option doesn't actually do anything.

Ian Ray
  • 378
  • 2
  • 18
  • The answer is "yes", you can do this. Since apparently you can't there must be something else going wrong. Please explain further/include more details. I created a new C# class library project, set it to .NET 4.5.2, added a refence to the ValueTuple nuget package, then tried code similar to what you're asking about in the title and it works. – Lasse V. Karlsen Sep 22 '17 at 22:55
  • Fascinating, I just tried the same. I was unable to get it to work. I made a completely new project, installed specified nuget-packages, reverted to .NET 4.5.2, and added the function signature `public (string, int) GetTuple()`. Received the same compiler errors. If you go to Project > Properties > Build > Advanced, what is your lang-version option set to? I am using C# Latest Major version (default) – Ian Ray Sep 22 '17 at 23:05
  • Alright. I guess the solution is that having `ctrl + .` take care of the installation of `System.ValueType` for you is what ultimately links it all up correctly. However, if I install `System.ValueType` manually from nuget package manager then we have issues. That's strange. – Ian Ray Sep 22 '17 at 23:09
  • I never thought that uninstalling it and reinstalling it would do it. Thanks, Lasse, you were a big help my friend. – Ian Ray Sep 22 '17 at 23:13
  • Possible duplicate of [Predefined type 'System.ValueTuple´2´ is not defined or imported](https://stackoverflow.com/questions/38382971/predefined-type-system-valuetuple%c2%b42%c2%b4-is-not-defined-or-imported) – Wai Ha Lee Feb 26 '19 at 16:56

1 Answers1

3

The solution to my issue was to uninstall the version of System.ValueType that I had installed manually and let the ctrl + . assistant take care of installing it.

Ian Ray
  • 378
  • 2
  • 18