Windows phone 7 无法使用xmlns:cl=";“名称空间”;在XAML中

Windows phone 7 无法使用xmlns:cl=";“名称空间”;在XAML中,windows-phone-7,xaml,namespaces,xml-namespaces,xamlparseexception,Windows Phone 7,Xaml,Namespaces,Xml Namespaces,Xamlparseexception,在我的WP7解决方案中,我有一个PhoneClassLibrary1程序集。 在它的AssemblyInfo.cs中,我有 [assembly: XmlnsPrefix("FooNamespace", "cl")] [assembly: XmlnsDefinition("FooNamespace", "PhoneClassLibrary1")] 我在PhoneClassLibrary1 using System.Windows.Controls; namespace PhoneClassLi

在我的WP7解决方案中,我有一个
PhoneClassLibrary1
程序集。 在它的AssemblyInfo.cs中,我有

[assembly: XmlnsPrefix("FooNamespace", "cl")]
[assembly: XmlnsDefinition("FooNamespace", "PhoneClassLibrary1")]
我在
PhoneClassLibrary1

using System.Windows.Controls;

namespace PhoneClassLibrary1
{
    public class Class1 : Control {}
}

PhoneApp1
同一解决方案中的项目的主页面为

<phone:PhoneApplicationPage 
    x:Class="PhoneApp1.MainPage"
    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:cl="FooNamespace">

    <cl:Class1/>

</phone:PhoneApplicationPage>
在该应用程序成功启动之后


如果我检查PhoneApp1.xap(这是一个部署包),我可以看到以下生成的AppManifest.xml

<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="PhoneApp1" EntryPointType="PhoneApp1.App" RuntimeVersion="4.7.50308.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="PhoneApp1" Source="PhoneApp1.dll" />
    <AssemblyPart x:Name="PhoneClassLibrary1" Source="PhoneClassLibrary1.dll" />
    <AssemblyPart x:Name="PhoneClassLibrary1" Source="PhoneClassLibrary1.dll" />
  </Deployment.Parts>
</Deployment>


这不是打字错误。只有当
我对XmlnsPrefixAttribute的假设是,它为工具提供了一个关于首选项的提示,并且是可选的时,应用程序才能运行。XAML中的有效xmlns定义为:-
xmlns:cl=“clr名称空间:FooNamespace;Assembly=PhoneClassLibrary1”

clr名称空间前缀用于生成包含名称空间和包含所需类型的程序集的有效Uri。

我在
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" EntryPointAssembly="PhoneApp1" EntryPointType="PhoneApp1.App" RuntimeVersion="4.7.50308.0">
  <Deployment.Parts>
    <AssemblyPart x:Name="PhoneApp1" Source="PhoneApp1.dll" />
    <AssemblyPart x:Name="PhoneClassLibrary1" Source="PhoneClassLibrary1.dll" />
    <AssemblyPart x:Name="PhoneClassLibrary1" Source="PhoneClassLibrary1.dll" />
  </Deployment.Parts>
</Deployment>