5

我在向我的 wp7 项目添加资源时遇到问题。我已经添加了

        <resources:LocalizedStrings x:Key="LocalizedStrings"/>

在运行应用程序后,我收到这样的 XamlParseException: Unknown parser error: Scanner 2147500037。

这是代码。

        <Application 
x:Class="MyProject.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:vm="clr-namespace:MyProject.ViewModels;assembly=MyProject.ViewModels"
xmlns:resources="clr-namespace:MyProject.Resources;assembly=MyProject.Resources">
<Application.Resources>
    <ResourceDictionary>

        <resources:LocalizedStrings x:Key="LocalizedStrings"/>
        <vm:ViewModelLocator x:Key="Locator"/>

        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="styles/globalstyles.xaml"/>
            <ResourceDictionary Source="styles/UserStyles.xaml"/>
            <ResourceDictionary Source="styles/DialogStyles.xaml"/>
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Application.Resources>

<Application.ApplicationLifetimeObjects>
    <shell:PhoneApplicationService 
        Launching="Application_Launching" Closing="Application_Closing" 
        Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects></Application>
4

1 回答 1

4

通过创建项目 MyProject.LocalizedResources 而不是 MyProject.Resources 解决此问题

xmlns:resources="clr-命名空间:MyProject.LocalizedResources;assembly=MyProject.LocalizedResources"

现在效果很好。

项目名称中的单个单词资源导致错误!:(

于 2012-08-15T06:36:03.760 回答