【发布时间】:2015-06-25 11:18:05
【问题描述】:
我正在开发 Windows Phone 8.1(WinRT) windows store app 项目。我为 DataConnection、ServiceConnection 等开发了不同的 PCL 项目……我在 WP 8.1 项目中引用了这些项目。在 DataConnection pcl 中,我拥有在 .net 4.0 目标下创建的所有 .resx 文件。我所有的 PCL 项目都是在 Xamarin Studio 中为跨平台(Android、iOS、WP)创建的。现在我在 Visual Studio Premium 2013 中打开了我的项目,以便开发 WP 项目并将我的目标框架从 .net 4.0 更改为 4.5,因为 WP 8.1 需要 4.5 作为目标。
更改后,我无法从 Windows Phone 项目中读取字符串资源值。在执行以下行时,
string test = Test.String1;
它抛出异常,
An exception of type 'System.ArgumentNullException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: Value cannot be null.
异常跟踪:
System.ArgumentNullException was unhandled by user code
HResult=-2147467261
Message=Value cannot be null.
Parameter name: format
Source=mscorlib
ParamName=format
StackTrace:
at System.String.Format(IFormatProvider provider, String format, Object[] args)
at System.Environment.GetResourceString(String key, Object[] values)
at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
at App.Core.Resources.Test.get_String1()
at App.Forms.WindowsPhoneUI.MainPage..ctor()
at App.Forms.WindowsPhoneUI.App_Forms_WindowsPhoneUI_XamlTypeInfo.XamlTypeInfoProvider.Activate_4_MainPage()
at App.Forms.WindowsPhoneUI.App_Forms_WindowsPhoneUI_XamlTypeInfo.XamlUserType.ActivateInstance()
InnerException:
截图:
这里出了什么问题?请有人帮我解决这个问题。
【问题讨论】:
-
检查您的 Test 对象是否不为空。
标签: c# .net windows-store-apps resourcebundle