首页 > 解决方案 > VisualStudio PathTooLongException

问题描述

我遇到了 VisualStudio 的问题 - 2017 Pro 和 2019 Pro。如果我尝试打开我的解决方案,我会收到以下错误:

在此处输入图像描述

VS2019 中的报错信息有点不同,但含义相同。当我调查 ActivityLog 文件时,只有这个节点对此问题感兴趣:

<entry>
<record>698</record>
<time>2019/07/03 08:14:00.064</time>
<type>Error</type>
<source>Editor or Editor Extension</source>
<description>System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.&#x000D;&#x000A;
at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32  maxPathLength, Boolean expandShortPaths)&#x000D;&#x000A;
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)&#x000D;&#x000A;
   at System.IO.Path.InternalGetDirectoryName(String path)&#x000D;&#x000A;
   at Microsoft.VisualStudio.ErrorListPkg.PathColumnDefinition.GetCachedDirectoryName(ITableEntryHandle entry)&#x000D;&#x000A;
   at Microsoft.VisualStudio.ErrorListPkg.PathColumnDefinition.TryCreateStringContent(ITableEntryHandle entry, Boolean truncatedText, Boolean singleColumnView, String&amp; content)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Shell.TableControl.TableEntryHandleExtensions.TryCreateStringContent(ITableEntryHandle entry, ITableColumnDefinition column, Boolean truncatedText, Boolean singleColumnView, String&amp; content)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Shell.TableControl.Implementation.TableControl.GenerateFiltersForColumn(UpdateResults results, ITableColumnDefinition columnDefinition)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Shell.TableControl.Implementation.TableControl.UpdateEntryFilters(UpdateResults results, HashSet`1 variableColumns)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Shell.TableControl.Implementation.TableControl.UpdateEntries(HashSet`1 variableColumns, Boolean anyColumnChanges, List`1&amp; frozenSinksAwaitingDisposal)&#x000D;&#x000A;
   at Microsoft.VisualStudio.Shell.TableControl.Implementation.TableControl.&lt;UpdateEntriesAsync&gt;d__182.MoveNext()&#x000D;&#x000A;
--- End of stack trace from previous location where exception was thrown ---&#x000D;&#x000A;
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)</description>
</entry>

有什么方法可以准确地找出错误的路径吗?我怀疑 SpecFlow addid 引起了这个问题。但是如果我禁用这个插件,什么都不会改变。

另一个队友使用相同的解决方案没有这个问题。

标签: visual-studiopathtoolongexception

解决方案


我以某种方式摆脱了这个错误信息。我不明白如何,但让我分享我所做的步骤。

  1. 我开始一一从解决方案中删除项目,以找出导致问题的项目。
  2. 一旦找到坏的,我就恢复了 GIT 上的所有更改。

  3. 我对这个项目中的文件和文件夹重复了这种方法。当我删除一些文件并重新启动VS时,问题就消失了。

  4. 再次恢复 GIT 上的所有更改。

  5. 瞧,这个错误在 2017 年和 2019 年都是历史。SLN 或 CSPROJ 文件中没有任何变化。


推荐阅读