简体   繁体   中英

How can I resolve false error messages in Visual Studio for a Blazor Server Side project?

Issue with false error messages in Visual Studio, help needed

Hello everyone,

I'm experiencing a peculiar issue in Visual Studio where I'm seeing error messages that do not actually exist. While I am still able to build the project without any problems, these false errors are causing hindrances. One specific error is occurring in the line " @typeparam T_User where T_User: IdentityUser<Guid>, IUser " in file Authorize.razor in project ... Security where I'm getting an RZ1017 error at the " where " keyword. I really don't know why. In another project another.razor file it works fine. The strange thing is that this error is also present in another project within the solution, but in that case, it prevents successful builds. I want to note that this problem was not present three hours ago. It seems to have occurred suddenly without any changes made to the code or project settings.

Here are the steps I've already tried to resolve the issue:

1. Closed all documents in Visual Studio.

2. Restarted Visual Studio multiple times.

3. Deleted the "bin" and "obj" folders.

4. Cleared the Roslyn cache.

5. Cleared the ComponentModel cache.

6. Deleted the ".vs" folder.

7. Cloned the repository again.

8. Restarted the PC.

9. Used the Visual Studio Installer to "Repair" Visual Studio

Here's the link to the repository : https://github.com/NicoVolling/NicoVolling-Web

Visual Studio Version: Community Edition 2022 17.6.0

Project Details: .NET 7, Asp.NET, Blazor Server Side, Entity Framework, Identity

Authorize.razor from Security Project:

@using Microsoft.AspNetCore.Identity;
@using NiVo.Framework.Components;
@using NiVo.Framework.Security.Authorization;
@using NiVo.Framework.Security.Identity;

@inherits BaseComponent

@typeparam T_User where T_User : IdentityUser<Guid>, IUser
@typeparam T_LoginPage
@typeparam T_404Page

@if (Display && ChildContent != null)
{
    @ChildContent(User)
}
else if(ShowLoginIfNotAuthorized && !ValidateAsync(BaseRules.Authenticated).Result)
{
    <DynamicComponent Type="typeof(T_LoginPage)" Parameters="@(new Dictionary<string, object>() { { "ReturnUrl", NavigationManager.Uri.Replace(NavigationManager.BaseUri, "") } })" />
}
else if(Show404NotAuthorized)
{
    <DynamicComponent Type="typeof(T_404Page)" />
}

Screenshot: Errors in File Authorize.razor

Security.csproj from Security Project:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
      <OutputType>Library</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\NiVo.Framework.Components\NiVo.Framework.Components.csproj" />
    <ProjectReference Include="..\NiVo.Framework.Data\NiVo.Framework.Data.csproj" />
  </ItemGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
        <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
    </ItemGroup>

</Project>

If anyone has encountered a similar problem or has any suggestions on how to resolve this issue, I would greatly appreciate your help. Please let me know if you need any further information.

Thank you in advance!

Nico Volling

EDIT #1:

I tried in a Windows 11 Dev VM with Visual Studio Community Edition 2022 17.5.5: Works fine. I don't know if it depends on Settings, Version or something else. Next Step: I'm currently updating VS in the VM. If the problem appears, then its a version problem.

EDIT #2:

Its a version problem. Just upgraded to version 17.6: literally nothing is fine. So i need to go back to Version 17.5.5 or 17.5.IDontKnow

EDIT #3:

This Issue still exists in version 17.6.2.

The final Solution to my Problem was to roll back from Visual Studio Version 17.6.

See Edit #2 of my Question:

Its a version problem. Just upgraded to version 17.6: literally nothing is fine. So i need to go back to Version 17.5.5 or 17.5.IDontKnow

So this is the complete answer to my question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM