VSTS : Different checksum values given for '*.g.cs' Files 的 WPF 警告

标签 wpf xaml visual-studio-2008

在 Visual Studio 2008 Team System 中,这是我的警告:

Different checksum values given for '<some folder>' ...\Visual Studio 2008\Projects\...
\Debug\...\SomeFile.g.cs
SomeFile.g.cs 中的违规行文件是:
#pragma checksum "..\..\..\..\..\..\...\SomeFile.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "A18BC47B27EC4695C69B69F1831E3225"

我删除了所有 *.g.cs解决方案中的文件并重建,所有警告都回来了。这到底是什么?

最佳答案

生成 GUID 时,Visual Studio 似乎无法正确处理很长的路径。我通过将两个不同的文件添加到长路径中并重现了您所看到的行为来确认这一点。如果您查看有问题的 SomeFile.g.cs 文件,您会注意到这两个文件的 guid 是相同的。显然,Visual Studio 在生成此 GUID 时只检查文件路径的前 x 个字符。

C:\Users\Developer\Documents\Visual Studio 2008\Projects\WpfApplication1\WpfApplication1\obj\Debug\LongFolderNameLongFolderNameLongFolderName\LongFolderNameLongFolderNameLongFolderName\LongFolderNameLongFolderNameLongFolderName\SomeFileName1.g.cs(1,1): warning CS1697: Different checksum values given for 'c:\Users\Developer\Documents\Visual Studio 2008\Projects\WpfApplication1\WpfApplication1\LongFolderNameLo'
C:\Users\Developer\Documents\Visual Studio 2008\Projects\WpfApplication1\WpfApplication1\obj\Debug\LongFolderNameLongFolderNameLongFolderName\LongFolderNameLongFolderNameLongFolderName\LongFolderNameLongFolderNameLongFolderName\SomeFileName2.g.cs(1,1): (Related location)

从 .g.cs 文件:
#pragma checksum "..\<snipped>\SomeFileName1.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "F21D94943016E57893CEB405BE12ADEA"
#pragma checksum "..\<snipped>\SomeFileName2.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "C67F2F8C841E2C338E5FCDC5037E8454"

至于解决方案,我想您可以缩短路径或(更有可能)忽略这些警告。 :)

关于VSTS : Different checksum values given for '*.g.cs' Files 的 WPF 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1890159/

相关文章:

javascript - 如何从 WPF WebBrowser 控件调试页面的 JavaScript 代码

wpf - 将自定义 WPF 控件放置在 StackPanel 中

c# - 如何读取项目根目录中的文本文件?

wpf - 类型 'Window'不支持直接内容

c++ - 在 Visual Studio 中使用 C++ 的条件断点

c# - 在没有数据绑定(bind)的情况下在 XAML 中应用值转换器

c# - 找不到资源WPF工具包

xaml - 为弹出窗口设置整页高度

c++ - 将 xmllite.lib 添加到 Visual Studio 2008

visual-studio - 注册程序集时出现错误 MSB3216