简体   繁体   English

为 Blazor 组件生成的文件的文件路径太长时出错

[英]Error when the filepath for a generated file for a Blazor component is too long

I am trying to create a Component in Blazor server application but I get this error:我试图在 Blazor 服务器应用程序中创建一个组件,但出现此错误:

Severity Code Description Project File Line Suppression State Error CS0016 Could not write to output file 'C:\Users\UserName\Documents\Projects\FolderProject\ProjectName\obj\Debug.net6.0\generated\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_HRM_Xxxxxxxxxxxxxxx_razor.g.cs' -- 'Could not find a part of the path 'C:\Users\UserName\Documents\Projects\FolderProject\ProjectName\obj\Debug.net6.0\generated\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_HRM_Xxxxxxxxxxxxxxx_razor.g.cs'.'严重性代码说明项目文件行抑制 State 错误 CS0016 无法写入 output 文件 'C:\Users\UserName\Documents\Projects\FolderProject\ProjectName\obj\Debug.net6.0\generated\Microsoft.NET.Sdk.884008.1470ators\SourceGenerators Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_HRM_Xxxxxxxxxxxxxxx_razor.g.cs' - '找不到路径的一部分 'C:\Users\UserName\Documents\Projects\FolderProject\ProjectName\obj\Debug.net6.0 \generated\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\Components_Pages_HRM_Xxxxxxxxxxxxxxx_razor.g.cs'。 ProjectName C:\Users\UserName\Documents\Projects\FolderProject\ProjectName\CSC 1 Active.项目名称 C:\Users\UserName\Documents\Projects\FolderProject\ProjectName\CSC 1 活动。

I tried to created a new project and add the same component name, that works perfect, even in for separate Blazor components library, it works fine.我尝试创建一个新项目并添加相同的组件名称,效果很好,即使在单独的 Blazor 组件库中,它也能正常工作。 If I Delete just one character x from this name, then the application works fine again..如果我从这个名字中只删除一个字符x ,那么应用程序又可以正常工作了。
Can some explain to me way?有人可以向我解释一下吗?
Note: My path component: application root => folder [component] => folder [Pages] => folder [HRM] => MyBlazorComponent.razor注意:我的路径组件:application root => folder [component] => folder [Pages] => folder [HRM] => MyBlazorComponent.razor

The problem is that the filepath of the generated Razor file is too long, over 260 characters to be exact (more on why this number here ).问题是生成的 Razor 文件的文件路径太长,准确地说超过 260 个字符(更多关于为什么这个数字在这里)。 The solution is either to move the solution to a folder where the filepath length won't/ doesn't exceed 260 characters (something like C:\Projects\[your solution folder] ).解决方案是将解决方案移动到文件路径长度不会/不超过 260 个字符的文件夹(类似于C:\Projects\[your solution folder] )。

Alternatively you can make Windows (newer than Windows 10 version 1607) accept paths over 260 characters by enabling long paths, you can do this by setting the registry key LongPathsEnabled in Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem to 1 .或者,您可以通过启用长路径使 Windows(比 Windows 10 版本 1607 更新)接受超过 260 个字符的路径,您可以通过将Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem中的注册表项LongPathsEnabled设置为1来实现。 (Also explained in this How-To Geek article) (在这篇How-To Geek 文章中也有解释)

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

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