Windows 8应用程序:找不到字符串

时间:2012-08-28 12:41:38

标签: xaml windows-8 microsoft-metro

我正在使用XAML和C#开发Windows 8应用程序。 我创建了一个用于存储本地化字符串的资源字典。

虽然按原样使用“< String>”标记,但编译器会识别它,但表示不支持它。

在我目前的配置中:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:s="using:System">

    <s:String x:Key="start">Start</s:String>
    <s:String x:Key="pause">Pause</s:String>
    <s:String x:Key="stop">Stop</s:String>

    <s:String x:Key="deleteSelected">Delete Selected</s:String>

    <s:String x:Key="timer">Timer</s:String>
    <s:String x:Key="timers">Timers</s:String>
    <s:String x:Key="stopper">Stopper</s:String>
    <s:String x:Key="stoppers">Stoppers</s:String>
    <s:String x:Key="alarmClock">Alarm Clock</s:String>
    <s:String x:Key="alarmClocks">Alarm Clocks</s:String>

    <s:String x:Key="recordLap">Record Lap</s:String>
</ResourceDictionary>

这是调试输出:

'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\Gilad Naaman\documents\visual studio 2012\Projects\TimeLord\TimeLord\bin\Debug\AppX\TimeLord.exe', Symbols loaded.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\system32\WinMetadata\Windows.UI.Xaml.winmd', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.InteropServices.WindowsRuntime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.InteropServices.WindowsRuntime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\system32\WinMetadata\Windows.ApplicationModel.winmd', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Collections\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Collections.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ObjectModel\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ObjectModel.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\system32\WinMetadata\Windows.Foundation.winmd', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.WindowsRuntime.UI.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.WindowsRuntime.UI.Xaml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.WindowsRuntime\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.WindowsRuntime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
A first chance exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in TimeLord.exe
WinRT information: The type 'String' was not found. [Line: 13 Position: 44]
An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred in TimeLord.exe but was not handled in user code
WinRT information: The type 'String' was not found. [Line: 13 Position: 44]
Additional information: Unspecified error
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\11.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.DLL'
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
A first chance exception of type 'System.Exception' occurred in TimeLord.exe
'TimeLord.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Diagnostics.Debug\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Diagnostics.Debug.dll'
The program '[4992] TimeLord.exe: Program Trace' has exited with code 0 (0x0).
The program '[4992] TimeLord.exe: Managed (v4.0.30319)' has exited with code -1073741189 (0xc000027b).
Activation of the Windows Store app 'f109d0b0-d566-47cd-9551-2969e7b4abab_capbppsrwz44p!App' failed with error 'Windows was unable to communicate with the target application.  This usually indicates that the target application's process aborted. More information may be available in the Debug pane of the Output window (Debug->Windows->Output)'.

1 个答案:

答案 0 :(得分:4)

请改用:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

     <x:String x:Key="start">Start</x:String>

请参阅this example on the MSDN