Latet beta c# 7 tupels are not working


With Tuples samples I am getting following error.

CS8179 Predefined type 'System.ValueTuple`2' is not defined or imported


  • edited November 2016
    Run the following query in C# Statements mode:

    Process.Start (Path.GetDirectoryName (GetType().Assembly.Location));

    and then click on the folder in explorer (it might be behind LINQPad).

    Do you see any subdirectories starting with 'shadow'? And if you open one of them, is there a file present called 'System.ValueType.dll'?
  • Can you try a couple of things and tell me if it makes any difference.

    First, explicitly add a reference to that file.

    If that doesn't help, try running the following query, which includes a reference to the System.ValueTuple nuget package:

  • That didn't help either.
  • Is this happening on just one machine? Can anyone else repro it?
  • I can repo this; however, I have only seen this behavior on one of several machines. The machine that has the problem is using Windows 10 Insider Build (slow track), Visual Studio 2017 Ent. RC, Visual Studio 2015.3 and several dotnet core sdks (1.0.0-preview3-004056, 1.0.0-preview2-003131, 1.0.0-preview2-003121, 1.0.0-preview2-1-003177).

    ...this isn't a production machine ;-)
  • If it helps, the CS8179 error is visible in Intellisense; i.e. before the code is actually compiled and ran. There's red squiggles...
  • On the machine that I am experiencing the "System.TupleValue'2 is not defined or imported", I am also getting that same error message inside the newest version of Visual Studio 2017 RC( v15.0.26009.0). I don't know enough about the Roslyn compiler services but since I'm experiencing shared behavior between the two applications, I'm guessing the problem may be due to something like that. May not be anything to do with Roslyn....maybe completely a Windows 10 insider build issue....
  • edited January 2
    Every time I start LinqPad, System.ValueTuple.dll gets automatically added under %AppData%\..\Local\Temp\LINQPad5\System.ValueTuple. If I delete this folder, things start to work as expected. I have VS 2017 RC installed.

    When before deleting the folder, I tried this:

    System.Runtime.CompilerServices.TupleElementNamesAttribute namesAttr;

    I got this error:

    CS0433 The type 'TupleElementNamesAttribute' exists in both 'System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    which led me to look for System.ValueTuple.dll and in turn to delete the folder under temp.

    "Tuples" linqpad sample mentions in the end:

    // Tuples rely on a new type called System.ValueTuple, in the NuGet package of the same name.
    // LINQPad includes this automatically, so you don't have to import anything.

    After deleting the folder, I was always getting a warning that %AppData%\..\Local\Temp\LINQPad5\System.ValueTuple\System.ValueTuple.dll does not exist, although things worked as expected. To avoid the warning and while waiting until Joe fixes this, I compiled an empty dll named System.ValueTuple.dll, which I use to overwrite the one LP writes in this folder when it starts.
    The overwrite is conveniently done by a little LinqPad script:

    var dummy = Environment.ExpandEnvironmentVariables(@%AppData%\..\Local\Temp\LINQPad5\System.ValueTuple.dll);
    var extra = Environment.ExpandEnvironmentVariables(@%AppData%\..\Local\Temp\LINQPad5\System.ValueTuple\System.ValueTuple.dll);
    File.Copy(dummy, extra, true);

    It seems to me that when a system already has all the necessary, LINQPad should not try to add this reference automatically.
  • CS0433 The type 'TupleElementNamesAttribute' exists in both 'System.ValueTuple, Version=, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' and 'mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    I don't understand how that attribute can exist in mscorlib. The mscorlib assembly is part of CLR 4 which was released in 2010.

    The types for value tuples are supposed to come from the System.ValueType.dll assembly, which is available on NuGet. If you add a reference to this assembly, LINQPad will not add its own automatic reference to System.ValueType.

    Is there something I'm missing?
  • Using ILSpy, I can confirm that the mscorlib.dll that I have on my problematic machine includes System.ValueTuple in mscorlib.

    - Windows 10 Enterprise Insider Preview. Build 14986.rs_prerelease.161202-1928.
    - Visual Studio Enterprise 2017RC/15.0.0-RC.4+26206.0
    - dotnet --version := 1.0.0-rc4-004771
    - mscorlib ilspy header:
    // C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
    // mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089
    // ...
    // [assembly: AssemblyFileVersion("4.6.2012.0")]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!