我创建了一个新的 VS 解决方案,它需要包含来自另一个解决方案的修改后的文件子集。两种解决方案都具有“Microsoft.Windows.Controls”的默认命名空间。旧解决方案中的程序集名为“WPFToolkit”,新程序集名称为“DatePicker”。我复制到新解决方案的文件之一是名为“ExceptionStringTable.txt”的嵌入式资源。内容如下所示,虽然我不确定它是什么格式:
; DataGrid 选择命令 DataGrid_SelectAllCommandText=全选 DataGrid_SelectAllKey=Ctrl+A DataGrid_SelectAllKeyDisplayString=Ctrl+A
我将文件的“构建操作”设置为“嵌入式资源”,就像在原始解决方案中一样。在运行时,它是这样加载的:
私有静态资源管理器_resourceManager = new ResourceManager("ExceptionStringTable", typeof(SR).Assembly);
执行代码后
_resourceManager.GetString(id.String)我收到了这个运行时异常:
System.Resources.MissingManifestResourceException 发生 Message="Could not find any resources applicable for the specifiedculture or the Neutralculture. 确保在编译时将 \"ExceptionStringTable.resources\" 正确嵌入或链接到程序集 \"DatePicker\" 中,或者所需的所有附属程序集都是可加载和完全签名的。”
以编程方式列出程序集的资源名称,我得到这个:
DatePicker.g.resources Microsoft.Windows.Controls.Resources.ExceptionStringTable.txt Microsoft.Windows.Controls.Properties.Resources.resources
我必须做什么才能将 ExceptionStringTable.txt 转换为等效的 .resources 然后嵌入到我的程序集中,以便 uri“ExceptionStringTable”找到它?