简体   繁体   English

如何解决 Blazor 服务器端项目在 Visual Studio 中的虚假错误消息?

[英]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 Visual Studio 中的错误消息问题,需要帮助

Hello everyone,大家好,

I'm experiencing a peculiar issue in Visual Studio where I'm seeing error messages that do not actually exist.我在 Visual Studio 中遇到了一个特殊问题,我看到了实际上并不存在的错误消息。 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.一个特定的错误发生在项目中文件Authorize.razor中的“ @typeparam T_User where T_User: IdentityUser<Guid>, IUser ”行中... Security ,我在“ where ”关键字处收到RZ1017错误。 I really don't know why.我真的不知道为什么。 In another project another.razor file it works fine.在另一个项目中,another.razor 文件工作正常。 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. 1.关闭Visual Studio中的所有文档。

2. Restarted Visual Studio multiple times. 2.多次重启Visual Studio。

3. Deleted the "bin" and "obj" folders. 3.删除了“bin”和“obj”文件夹。

4. Cleared the Roslyn cache. 4.清除 Roslyn 缓存。

5. Cleared the ComponentModel cache. 5.清除了ComponentModel缓存。

6. Deleted the ".vs" folder. 6.删除了“.vs”文件夹。

7. Cloned the repository again. 7.再次克隆存储库。

8. Restarted the PC. 8.重新启动电脑。

9. Used the Visual Studio Installer to "Repair" Visual Studio 9.使用 Visual Studio 安装程序“修复”Visual Studio

Here's the link to the repository : https://github.com/NicoVolling/NicoVolling-Web这是存储库的链接: https://github.com/NicoVolling/NicoVolling-Web

Visual Studio Version: Community Edition 2022 17.6.0 Visual Studio 版本:社区版 2022 17.6.0

Project Details: .NET 7, Asp.NET, Blazor Server Side, Entity Framework, Identity项目详情: .NET 7、Asp.NET、Blazor 服务器端、实体框架、身份

Authorize.razor from Security Project:来自安全项目的 Authorize.razor:

@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屏幕截图:文件 Authorize.razor 中的错误

Security.csproj from Security Project:来自安全项目的 Security.csproj:

<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:编辑#1:

I tried in a Windows 11 Dev VM with Visual Studio Community Edition 2022 17.5.5: Works fine.我在带有 Visual Studio Community Edition 2022 17.5.5 的 Windows 11 Dev VM 中进行了尝试:工作正常。 I don't know if it depends on Settings, Version or something else.我不知道这是否取决于设置、版本或其他因素。 Next Step: I'm currently updating VS in the VM.下一步:我目前正在更新 VM 中的 VS。 If the problem appears, then its a version problem.如果出现问题,那就是版本问题。

EDIT #2:编辑#2:

Its a version problem.是版本问题。 Just upgraded to version 17.6: literally nothing is fine.刚刚升级到 17.6 版:字面上没有什么是好的。 So i need to go back to Version 17.5.5 or 17.5.IDontKnow所以我需要 go 回到版本 17.5.5 或 17.5.IDontKnow

EDIT #3:编辑#3:

This Issue still exists in version 17.6.2.此问题在 17.6.2 版本中仍然存在。

The final Solution to my Problem was to roll back from Visual Studio Version 17.6.我的问题的最终解决方案是从 Visual Studio 版本 17.6 回滚。

See Edit #2 of my Question:请参阅我的问题的编辑#2:

Its a version problem.是版本问题。 Just upgraded to version 17.6: literally nothing is fine.刚刚升级到 17.6 版:字面上没有什么是好的。 So i need to go back to Version 17.5.5 or 17.5.IDontKnow所以我需要 go 回到版本 17.5.5 或 17.5.IDontKnow

So this is the complete answer to my question.所以这是我的问题的完整答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Blazor 服务器端的 CircuitHandler 中调用方法? - How can I invoke method in CircuitHandler of Blazor server-side? 在Visual Studio项目上连接服务器和客户端 - connect a server and client side on a visual studio project 在 Visual Studio 中运行后端时如何运行 Blazor 客户端? - How to run Blazor client side when running backend in Visual Studio? Visual Studio C# 我可以使用哪个 Class 库项目引用 Blazor 项目 - Visual Studio C# with which Class Library Projects can I reference a Blazor Project 运行 Blazor 服务器端项目时出现 browserLink 错误 - browserLink error when run Blazor server side project 在 Visual Studio 2019 中找不到“Blazor App”项目模板 - Can not find “Blazor App” project template in Visual Studio 2019 无法在默认Blazor服务器端项目中找到Razor页面 - Can't Locate Razor Pages in Default Blazor Server Side Project 如何在 Visual Studio 中复制错误消息 - How do I copy error messages in Visual Studio 如何向服务器端 Blazor 项目添加控制器(而非视图)支持 - How to add controller (not view) support to a server-side Blazor project 在没有Visual Studio的情况下,如何在服务器的asp.net项目中包含库? - how i can include library in asp.net project on the server without visual studio?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM