I can't return Value Tuple from C# Class Library to ASP.net Core 2.1 MVC app, so I made a new solution to test only that point and it still did it.
Class Library (.net Framework 4.7):
namespace ClassLibrary1
{
public class Class1
{
public (bool Success, string ReturnMessage) abc()
{
return (true, "hi");
}
}
}
.net Core 2.1 MVC Controller:
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
public string Index()
{
var c = new Class1();
var x = c.abc();
return "";
}
}
}
I get this error in the MVC app at c.abc()
:
Reference to type 'ValueTuple<,>' claims it is defined in 'mscorlib', but it could not be found
If I create and return a Value Tuple within either project, it works.
I found this but it didn't help to install those Nuget packages (also why would that be required)? Predefined type 'System.ValueTuple´2´ is not defined or imported
How can I successfully call this from the MVC app?
you cannot call .Net Framework 4.7 class library from Asp.Net Core.
You can use .Net Standard, or ASP.Net Core for your Class Library.