[英]Blazor, Added a .razor page in a SubFolder, Now app doesn't start
I have a folder structure /Pages/Home/... with some pages that works, Now I ccreated a subfolder in Home: /Pages/Home/DrawerComponents and added a.razor to it with the full path: /Pages/Home/DrawerComponents/SubFolders.razor.我有一个文件夹结构 /Pages/Home/... 有一些可用的页面,现在我在 Home 中创建了一个子文件夹:/Pages/Home/DrawerComponents 并添加了 a.razor 到它的完整路径:/Pages/Home/抽屉组件/子文件夹.razor。
But the new.razor page causes app not to start, I use VS 2019 16.11.11 and Windows Forms with Blazor .NET 6.0.但是new.razor页面导致app无法启动,我用VS 2019 16.11.11和Windows Forms和Blazor .NET 6.0。
The SubFolders.razor content is: SubFolders.razor 的内容是:
@layout MainLayout
@page "/subfolder/{DrawerID:int}/{FolderID:int}/{FolderName:string}"
<RadzenLink Path="@($"/drawer/{DrawerID}")" Text="Folders"></RadzenLink>
<h3>@FolderName</h3>
@code {
[Parameter]
public int DrawerID { get; set; }
[Parameter]
public int FolderID { get; set; }
[Parameter]
public string FolderName { get; set; }
}
and all of the app services are Imported to it.并且所有应用程序服务都已导入其中。
Application does not start with error: NullReferenceException.应用程序未启动并出现错误:NullReferenceException。
when I exclude this.razor file App starts normaly.当我排除 this.razor 文件时,应用程序正常启动。 What is this and how to fix this?
这是什么以及如何解决这个问题?
EDIT: This is not a start page or a page that is referenced any where, When app starts.编辑:这不是起始页,也不是应用程序启动时在任何地方引用的页面。 So This exception may be caused by project structure not the famous NullReferenceException.
所以这个异常可能是由项目结构引起的,而不是著名的 NullReferenceException。
I changed the page directive to:我将页面指令更改为:
@page "/subfolder/{DrawerID:int}/{FolderID:int}/{FolderName}" @page "/subfolder/{DrawerID:int}/{FolderID:int}/{FolderName}"
and it runs good, I didn't enabled Nullable Reference Types so {FolderName:string} was Nullable and caused error.它运行良好,我没有启用 Nullable Reference Types 所以 {FolderName:string} 是 Nullable 并导致错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.