Intellisense无法识别部分课程 [英] Intellisense does not recognize partial class

查看:55
本文介绍了Intellisense无法识别部分课程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Blazorized运行一个Blazor测试项目(真棒),并且一切正常.但是,存在一个小而烦人的问题,那就是(2)页之一中(.cs)后面的代码无法识别它是剃刀文件的部分类.

I am running a Blazor test project with Blazorized (which is awesome) and everything works fine. However, there is a small, irritating issue and that is that the code behind (.cs) of one of the (2) pages does not recognize that it is a partial class of a razor file

因此,受保护的覆盖异步任务OnInitializedAsync()表示没有要覆盖的内容.代码工作正常,但是,这让我很烦.尝试过几次重建,退出Visual Studio并重新加载解决方案,还删除了缓存

So the protected override async Task OnInitializedAsync() says there is nothing to override. Code works fine however, but this is just bugging me. Tried rebuilding several times, quit Visual Studio and reload solution and also deleting the cache

希望有人有线索...

Hope somebody has a clue...

推荐答案

razor文件和razor.cs类应具有相同的命名空间.因此,如果您尝试更改razor.cs文件中的默认名称空间,它将开始出现此错误.

razor file and razor.cs class should have the same namespace. so if you try to change t default namespace in the razor.cs file, it will start giving you this error.

如果您不想使用默认的名称空间,则可以在两个文件中定义相同的名称空间.

if you don't want to use the default namespace then you can define the same namespace in both files.

您可以像上面的 @namespace TestNameSpace 一样在剃刀文件中定义名称空间.以及类似 namespace TestNameSpace 的局部类中.

you can define the namespace in the razor file like this @namespace TestNameSpace on top. and in partial class like namespace TestNameSpace.

通常,组件的名称空间是从应用程序的根名称空间以及应用程序中组件的位置(文件夹)派生的.如果应用程序的根名称空间是BlazorSample,并且Counter组件位于Pages文件夹中:

Typically, a component's namespace is derived from the app's root namespace and the component's location (folder) within the app. If the app's root namespace is BlazorSample and the Counter component resides in the Pages folder:

  • Counter组件的名称空间是BlazorSample.Pages.
  • 该组件的标准类型名称为BlazorSample.Pages.Counter.

参考: https://docs.microsoft.com/zh-cn/aspnet/core/blazor/components/?view=aspnetcore-5.0#namespaces

这篇关于Intellisense无法识别部分课程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆