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

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

并且在运行应用程序后,我收到这样的XamlParseException:未知的解析器错误: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>

最佳答案

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

xmlns:resources =“clr-namespace:MyProject.LocalizedResources; assembly = MyProject.LocalizedResources”

现在效果很好。

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

关于silverlight - 尝试添加资源时出现未知的解析器错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11914752/

10-12 15:51