我得到了错误
The file /DocomGUI;component/Resources/logo.jpg is not part of the project or its 'Build Action' property is not set to 'Resource'.
但是 logo.jpg
文件绝对是项目的一部分,Build Actions 也设置为“Resource”。
它位于项目根目录的 /Resources/
文件夹中,也位于同名的 Resources.resx
文件中。
我尝试重建解决方案,清理它,但仍然弹出错误。还有什么可能出错导致找不到文件?
代码:
<Window x:Class="DocomGUI.AboutWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="AboutWindow" Height="180" Width="220" Background="LightGray" MinWidth="220" MinHeight="115" MaxWidth="220" MaxHeight="115">
<Grid>
<Label Margin="0,66,24,48">DocomGUI</Label>
<Label Height="30" Margin="12,0,12,12" Name="VersionLabel" VerticalAlignment="Bottom"></Label>
<Image Margin="12,12,12,0" Stretch="Fill" Height="48" VerticalAlignment="Top" Source="/DocomGUI;component/Resources/logo.jpg" />
</Grid>
</Window>
最佳答案
我以前也遇到过这种情况,实际上只需重新启动 visual studio 即可自行修复。我不太确定为什么。
关于c# - 文件不是项目的一部分或生成操作未设置为 "Resource",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11632026/