2017-07-25 144 views
0

我不能在C#交互式窗口中使用元组;我得到以下错误:C#交互式不识别ValueTuple参考

(1,15): error CS8137: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference? 
(1,15): error CS8179: Predefined type 'System.ValueTuple`2' is not defined or imported 
(2,9): error CS0103: The name 'IsLiteralTypeName' does not exist in the current context 
(2,47): error CS8179: Predefined type 'System.ValueTuple`2' is not defined or imported 
(5,12): error CS8179: Predefined type 'System.ValueTuple`2' is not defined or imported 

这即使我添加了一个参考值类型组件:

#r "D:\MyProject\packages\System.ValueTuple.4.3.1\lib\netstandard1.0\System.ValueTuple.dll" 

我怎样才能利用价值的元组从C#互动窗口?

+0

添加NuGet包System.ValueTuple? –

+0

@EmanuelPirovano如何为C#交互式窗口添加Nuget包? –

回答

2

C:\Program Files (x86)\Microsoft Visual Studio\2017\<edition>\Common7\IDE\CommonExtensions\Microsoft\ManagedLanguages\VBCSharp\InteractiveComponents\CSharpInteractive.rsp 

为Visual Studio 2017年Remove /r:System.ValueTuple.dll

C:\Program Files (x86)\Microsoft Visual Studio\2017\<edition>\MSBuild\15.0\Bin\Roslyn\csi.rsp 

的命令行工具(csi.exe)