如何link资源文件?
How to link resource files?
我有一个 strings.resx 文件已复制到另一个项目。它有一个关联的 strings.designer.cs 文件。问题是,一旦我将它们添加到 VS.NET 项目中,它们就分开了。
在旧项目中,strings.designer.cs 是 strings.resx 的子项目。如果我双击 strings.resx,它会自动生成一个 strings1.designer.cs 文件。
如何重新创建关联?
我可以重现你的问题。
在新项目中导入资源后,如果您查看 .csproj 文件,您会发现包含 <Compile Include="string.Designer.cs" />
项目的 ItemGroup
部分,类似于以下内容
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
....
<Compile Include="string.Designer.cs" />
</ItemGroup>
因此,要解决您的问题,请执行以下操作
- 在 VisualStudio 中卸载项目。
- 右键单击已卸载的项目,然后从上下文菜单中 select "edit {your project name}"
- 找到包含您的
<Compile Include="string.Designer.cs" />
的 ItemGroup 部分
- 替换
<Compile Include="string.Designer.cs" />
来自
<Compile Include="string.Designer.cs">
<DependentUpon>string.resx</DependentUpon>
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
</Compile>
现在重新加载项目广告,您应该会在解决方案资源管理器中看到相关文件
我有一个 strings.resx 文件已复制到另一个项目。它有一个关联的 strings.designer.cs 文件。问题是,一旦我将它们添加到 VS.NET 项目中,它们就分开了。
在旧项目中,strings.designer.cs 是 strings.resx 的子项目。如果我双击 strings.resx,它会自动生成一个 strings1.designer.cs 文件。
如何重新创建关联?
我可以重现你的问题。
在新项目中导入资源后,如果您查看 .csproj 文件,您会发现包含 <Compile Include="string.Designer.cs" />
项目的 ItemGroup
部分,类似于以下内容
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
....
<Compile Include="string.Designer.cs" />
</ItemGroup>
因此,要解决您的问题,请执行以下操作
- 在 VisualStudio 中卸载项目。
- 右键单击已卸载的项目,然后从上下文菜单中 select "edit {your project name}"
- 找到包含您的
<Compile Include="string.Designer.cs" />
的 ItemGroup 部分
- 替换
<Compile Include="string.Designer.cs" />
来自
<Compile Include="string.Designer.cs"> <DependentUpon>string.resx</DependentUpon> <DesignTime>True</DesignTime> <AutoGen>True</AutoGen> </Compile>
现在重新加载项目广告,您应该会在解决方案资源管理器中看到相关文件