在我的WP7解決方案中,我有一個PhoneClassLibrary1
程序集。 在它的AssemblyInfo.cs我無法在XAML中使用xmlns:cl =「FooNamespace」
[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>
主要頁面編譯得很好。但是在運行時,我得到XamlParseException
{ 「類型 '的Class1' 沒有被發現,因爲 'FooNamespace' 是一個未知的命名空間。[線路:8位置:6]」}
我嘗試將名稱分配給控件<cl:Class1 x:Name="foo"/>
以使生成的代碼中引用Class1。相同XamlParseException
。
我修改了AppManifest.xml中的PhoneApp1
。請注意,AssemblyPart
標籤。
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Deployment.Parts>
<AssemblyPart x:Name="PhoneClassLibrary1" Source="PhoneClassLibrary1.dll" />
</Deployment.Parts>
</Deployment>
該應用程序啓動成功後。
如果我檢查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>
即不是一個錯字。應用程序可以只運行,如果<AssemblyPart x:Name="PhoneClassLibrary1"
指定TWICE中產生AppManifest.xml
我做錯什麼了嗎?我在一個控制項目上工作,該項目在多個解決方案中被重用,並且不想在所有這些衆多的項目中修改AppManifset.xml。
是否XmlnsDefinition
能夠在沒有AppManifset.xml修改的情況下工作?
我在http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/1a47600c-0dcd-42fa-81ef-3b00bde55402上提出了同樣的問題 –