'IResult (from Asp) not found in standard 2.0 project

I created a DLL project targeting .net standard 2.0.

With NuGet I added a reference to Microfosft.AspNetCore.Http. (2.2.2)

I created this class:

using System;
using Microsoft.AspNetCore.Http;

namespace netstdlib
{
   public class Class1
   {
      public IResult DoGet()
      {
         return null;
      }
   }
}

When I build I get

Build started...
1>------ Build started: Project: netstdlib, Configuration: Debug Any CPU ------
1>D:\PROJECTS\experiment\CS framework test\netstdlib\Class1.cs(10,25,10,32): error CS0246: 
  The type or namespace name 'IResult' could not be found (are you missing a using 
  directive or an assembly reference?)
1>Done building project "netstdlib.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 2 up-to-date, 0 skipped ==========

It seems to me it should find IResult in the library I'm using. What's wrong?



Solution 1:[1]

Thanks to Camilo for pointing out why IResult can't work. I did find a way that will work:

HttpResponseMessage as produced by HttpClient.GetAsync is usable in .net core. Whether or not these classes are usable in .net framework I didn't try, but I can use HttpResponseMessage to extract data in a Standard dll, and return that data to a .net framework project.

Solution 2:[2]

The IResult interface in the Microsoft.AspNetCore.Http namespace was added in ASP.NET Core 6, so you need to update if you want to use it.

See documentation: IResult Interface.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alan Baljeu
Solution 2 Camilo Terevinto