没有为“资源"提供默认或中立资源 [英] No default or neutral resource given for 'resource'

查看:100
本文介绍了没有为“资源"提供默认或中立资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个支持两种语言(en和de)的UWP应用.我既创建了Resource.resw文件,又创建了testfile.xml,这基本上是我的应用程序的数据源.如果我直接从Visual Studio(DEBUGRELEASE模式)运行该应用程序,则可以正常工作,但是一旦我从商店安装该应用程序或通过WinAppDeployCmd.exe将其侧面加载到设备中,它就不会从

I am building a UWP app which supports two languages (en and de). I have created both Resource.resw files and and a testfile.xml which is basically the datasource of my application. If I run the app directly from Visual Studio (DEBUG or RELEASE mode) it's working fine, but once I install it from the store or sideload it to the device via WinAppDeployCmd.exe it does not load the resource from Resources.resw

这是我在Strings目录中的文件结构:

This is my file structure inside the Strings directory:

我有指向Resources.resw文件中指定的测试文件的链接,如下所示:

I have the link to the testfile specified in the Resources.resw file like this:

启动该应用程序后,我将使用ResourceLoader检索Testfile键的值以加载正确的(en或de)文件.

Once the app is launched I use a ResourceLoader to retrieve the value of the Testfile key to load the right (en or de) file.

var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
var value = loader.GetString("Testfile");
var testfile = Path.Combine(Package.Current.InstalledLocation.Path + "/Strings/", value);

在构建过程中,这些警告会显示在输出窗口中

During the build process these warnings show up in the output window

MakePRI : warning 0xdef01051: No default or neutral resource given for 'Files/Project/Strings/testfile_de.xml'. The application may throw an exception for certain user configurations when retrieving the resources.
MakePRI : warning 0xdef00522: Resources found for language(s) 'en,de' but no resources found for default language(s): 'en-US'. Change the default language or qualify resources with the default language.

您是否知道为什么在通过商店安装应用程序或侧加载应用程序时未加载资源?

Do you have any idea why the resource is not loaded when the app is installed via the store or sideloaded?

推荐答案

为解决方案中的每个.csproj设置<DefaultLanguage>en</DefaultLanguage>

Set <DefaultLanguage>en</DefaultLanguage> for every .csproj in your solution

这篇关于没有为“资源"提供默认或中立资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆