I am trying to use the new tuple features in C# 7 in an ASP.NET MVC 5 app, using .NET version 4.6.1. and Visual Studio 2017 RC. To do so I referenced this article here: What's new in C# 7, which said to install System.ValueTuple via NuGet. When I did this, the tuple syntax started working for me like in this example code:
public void TupleCaller()
{
(var valOne, var valTwo) = TupleExample();
}
public (string, string) TupleExample()
{
return ("Tuple Item One", "Tuple Item Two");
}
However, when I run the app, my views immediately throw this error:
CS0012: The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
I have tried all of the following:
As soon as I uninstall the System.ValueTuple NuGet package and comment out the new Tuple code, everything renders properly in the views like before.
To add the Tuples feature, you may want to download and install the NuGet package. Step 1. Right click on the project name in Solution Explorer and select “Manage NuGet Package”. Step 2. Click on the "Browse" tab and type System.ValueTuple in the TextBox. You will see the package name, as shown below. Step 3.
The NuGet Gallery on nuget.org is the central package repository used by all package authors and consumers. Since C++ support in NuGet is brand new, there aren’t a lot of packages available in the NuGet Gallery yet. However, the CoApp project has created a few packages from open source libraries which you can use right now to get started.
Tuples in C++. 1. get() :- get() is used to access the tuple values and modify them, it accepts the index and tuple name as arguments to access a particular tuple element. 2. make_tuple() :- make_tuple() is used to assign tuple with values. The values passed should be in order with the values declared in tuple.
System. ValueTuple 4.5.0 Prefix Reserved Requires NuGet 2.12 or higher. For projects that support PackageReference, copy this XML node into the project file to reference the package. The NuGet Team does not provide support for this client. Please contact its maintainers for support.
I was having the same issue. I added the Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Nuget package (v1.0.3) to my project, and it works again!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With