2

我遇到了 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 引起了这个问题。但是如果我禁用这个插件,什么都不会改变。

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

4

3 回答 3

0

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

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

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

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

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

于 2019-07-08T09:49:12.227 回答
0

由于我的路径相当长,我也遇到了一些 PathTooLongExceptions。这是特别的。VS项目使用相对路径的情况。显然,缩短路径将解决很多这些问题。

但在对您的开发环境进行这种相当耗时的彻底检查之前,您可以做一些事情:

  1. 使用具有较短路径的符号链接或连接(例如 mklink /J MEDA Microsoft.Extensions.DependencyInjection.Abstractions)并在您的项目文件中使用它们
  2. 使用绝对路径:相对路径在幕后可能会变得很长,因为 Visual Studio 可能会引用 %(FullPath) ,它会很快超过 260 个字符

以上解决了我的问题。

于 2020-10-23T08:13:46.043 回答
-2

Windows,继承自 MS-DOS,使用简单 API 时的最大路径长度非常短。许多应用程序都将缓冲区固定到这个大小 - 寻找MAX_PATH- 因此没有简单的方法可以让事情变得更长。当 10MB 是典型的 HDD 大小时,248 个字符很多。

NTFS 和 Win32 可以支持更长的路径(2 15 -1 字符),但需要以正确的方式使用 API。许多,甚至是积极开发的,都没有。

我怀疑 Visual Studio,即使在其最新版本中,更不用说所有扩展,是否已经完全更新以处理长路径。

检查您是否避免在解决方案的根目录中使用长路径(Visual Studio 的默认项目位置在这里没有帮助)。

于 2019-07-04T13:49:22.793 回答