Hi @Jonathan ,
From your screenshots, it looks like your build is targeting net8.0, but you’ve installed Microsoft.AspNetCore.OpenApi 10.x. That version mismatch, plus a missing Microsoft.OpenApi reference, is what’s causing the CS0246 errors.
You have a couple of options to fix it:
Option A: Stay on .NET 8
- In
WebApp1.csproj, make sure you have:
<TargetFramework>net8.0</TargetFramework>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.*" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.*" />
- Then clean and rebuild:
dotnet clean
# optionally delete bin and obj folders
dotnet restore
dotnet build
Option B: Move to .NET 10
- Install the .NET 10 SDK (check with
dotnet --infoto confirm 10.x). - Update your
.csprojlike this:
<TargetFramework>net10.0</TargetFramework>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="10.0.2" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.*" />
- Then clean and rebuild as above.
Finally, make sure any files using these types have:
using Microsoft.OpenApi.Models;
Try these and let me know the result.