2015-11-29 18 views
2

在將Windows Phone 8.1(Silverlight)應用程序轉換爲Windows Phone 8.1應用程序時,我在加載應用程序時遇到崩潰。在Windows Phone 8.1的xaml中使用原始類型

我將問題縮小到我在App.xaml中的全局資源聲明。

<Application 
    x:Class="MyApp.App" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:System="using:System"> 

    <Application.Resources>   
     <System:Double x:Key="PhoneFontSizeSmall">18.667</System:Double> 
    </Application.Resource> 

如果我註釋掉System:Double資源,應用程序正在運行。

我試圖改變參考聲明使用以前?方式像

xmlns:System="clr-namespace:System;assembly=mscorlib" 

但一個抱怨找不到雙重命名空間......構建過程中。

欲瞭解更多信息,App.Initialization期間引發的異常如下。

{Windows.UI.Xaml.UnhandledExceptionEventArgs} 
    Exception: {"The text associated with this error code could not be found.\r\n\r\nCannot deserialize XBF metadata type list as '%1' was not found in namespace '%0'. [Line: 0 Position: 0]"} 
    Handled: false 
    Message: "Cannot deserialize XBF metadata type list as '%1' was not found in namespace '%0'. [Line: 0 Position: 0]" 
    Native View: To inspect the native object, enable native code debugging. 

我在這裏摸不着頭腦,Google/Bing目前還沒有幫助。

回答

1

用 'X' 的命名空間

<x:Double x:Key="PhoneFontSizeSmall">18.667</x:Double> 
+0

是的,這似乎工作。有沒有更多的解釋爲什麼默認的x命名空間正在工作,而不是導入的系統? x與xmlns鏈接:x =「http://schemas.microsoft.com/winfx/2006/xaml」 – Ronald

相關問題