Home

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

I have a .NET 4.5.2 library that ships in a NuGet package (with LINQPad samples). It uses C#7 tuples, so my NuGet package declares a dependency on the System.ValueTuple package. When attempting to run code (i.e., a Query) that depends on my NuGet package, it fails to run/compile with the following error: CS8179 Predefined type 'System.ValueTuple`2' is not defined or imported

If I create a new Query window and use tuples (without my NuGet package), it works fine. It's not clear whether there's an issue with LINQPad v5.22.02 and ValueTuples when pulled-in via a NuGet package or whether there's an issue with my NuGet package (it's a pretty simple package, so I'm not sure what could be wrong).

I've uploaded the script that reproduces the CS8179 issue with "instant share"...
http://share.linqpad.net/kx9ugx.linq

Any suggestions on how to fix this issue? Is anyone else able to reproduce the issue?

Thanks.

Comments

  • Do you have Framework 4.7 installed, or Framework 4.6?
  • Yes, I just installed the Windows 10 Creators Update: 460798 which includes Framework 4.7
  • Framework 4.7 includes System.ValueTuple in mscorlib.dll, so referencing System.ValueTuple.dll is unnecessary if you have Framework 4.7 installed. LINQPad detects this condition and removes the automatic reference to System.ValueTuple.dll (otherwise you end up with an ambiguous type exception).

    Given that your NuGet package references System.ValueTuple.dll, this would appear to make it incompatible with Framework 4.7: it wants to use the ValueTuple type in System.ValueTuple.dll, whereas anything you compile under Framework 4.7 will want to use the ValueTuple type in mscorlib.dll.

    Do you get the same problem in Visual Studio?
  • I created a new console application (targeting .NET 4.5.2) in Visual Studio 2017, installed my NuGet package, and ran the code (same as the .linq file from my initial forum post). It runs successfully.

    Do you recommend I modify my NuGet package to explicitly declare the System.ValueTuple package dependency for net45, yet explicitly exclude it from net47 and any other version that has those types built-in? I thought the System.ValueTuple package should do that, not mine. Is that correct?
Sign In or Register to comment.