2012-01-06 22 views
2

この例外に関して私を助けることができますか?私は私のアプリでここで提供されたナビゲーションレシピを使用しています。
http://windowsteamblog.com/windows_phone/b/wpdev/archive/2010/12/13/solving-circular-navigation-in-windows-phone-silverlight-applications.aspxwindows携帯電話のナビゲーションレシピの例外

これは私が得る例外です:

Exception message: Type 'System.Windows.Media.ImageSource' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. 
Stack trace: at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String message, Type type) 
    at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type) 
    at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type) 
    at System.Runtime.Serialization.DataContract.GetDataContract(RuntimeTypeHandle typeHandle, Type type, SerializationMode mode) 
    at System.Runtime.Serialization.DataContract.GetDataContract(Type type) 
    at System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper..ctor(Type type) 
    at System.Runtime.Serialization.ClassDataContract..ctor(Type type) 
    at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type) 
    at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type) 
    at System.Runtime.Serialization.DataContract.GetDataContract(RuntimeTypeHandle typeHandle, Type type, SerializationMode mode) 
    at System.Runtime.Serialization.DataContract.GetDataContract(Type type) 
    at System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper..ctor(Type type) 
    at System.Runtime.Serialization.ClassDataContract..ctor(Type type) 
    at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type) 
    at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type) 
    at System.Runtime.Serialization.DataContract.GetDataContract(RuntimeTypeHandle typeHandle, Type type, SerializationMode mode) 
    at System.Runtime.Serialization.DataContract.GetDataContract(Type type) 
    at System.Runtime.Serialization.DataMember.CriticalHelper.get_MemberTypeContract() 
    at System.Runtime.Serialization.XmlFormatWriter.WriteMember(SerializingObject serObj, Int32 memberIndex, ClassDataContract derivedMostClassContract) 
    at System.Runtime.Serialization.XmlFormatWriter.WriteClass(CallStackElement`1 callStackElement) 
    at System.Runtime.Serialization.XmlFormatWriter.Serialize(XmlObjectSerializerWriteContext context) 
    at System.Runtime.Serialization.XmlFormatWriter.InitializeCallStack(XmlWriterDelegator xmlWriterDel, Object obj, XmlObjectSerializerWriteContext writeContext, DataContract contract) 
    at System.Runtime.Serialization.CollectionDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context) 
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.WriteDataContractValue(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) 
    at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithoutXsiType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle declaredTypeHandle) 
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObjectContent(XmlWriterDelegator writer, Object graph) 
    at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph) 
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph) 
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph) 
    at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(Stream stream, Object graph) 
    at Microsoft.Phone.Shell.StreamPersister.Serialize(IDictionary`2 dictionary, IEnumerable`1 knownTypes) 
    at Microsoft.Phone.Shell.StreamPersister.Save(ShellPage shellPage, String key, IDictionary`2 dictionary, IEnumerable`1 knownTypes) 
    at Microsoft.Phone.Controls.PhoneApplicationPage.InternalOnNavigatedFrom(NavigationEventArgs e) 
    at System.Windows.Navigation.NavigationService.RaiseNavigated(Object content, Uri uri, NavigationMode mode, Boolean isNavigationInitiator, PhoneApplicationPage existingContentPage, PhoneApplicationPage newContentPage) 
    at System.Windows.Navigation.NavigationService.CompleteNavigation(DependencyObject content, NavigationMode mode) 
    at System.Windows.Navigation.NavigationService.ContentLoader_BeginLoad_Callback(IAsyncResult result) 
    at System.Windows.Navigation.PageResourceContentLoader.BeginLoad_OnUIThread(AsyncCallback userCallback, PageResourceContentLoaderAsyncResult result) 
    at System.Windows.Navigation.PageResourceContentLoader.<>c__DisplayClass4.<BeginLoad>b__0(Object args) 
    at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) 
    at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark& stackMark) 
    at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) 
    at System.Delegate.DynamicInvokeOne(Object[] args) 
    at System.MulticastDelegate.DynamicInvokeImpl(Object[] args) 
    at System.Windows.Threading.DispatcherOperation.Invoke() 
    at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority) 
    at System.Windows.Threading.Dispatcher.OnInvoke(Object context) 
    at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args) 
    at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam& pResult) 

Source page: /Views/MainPage.xaml 

答えて

2

例外は、ナビゲーションループソリューションとは何の関係もありません。

例外は、ImageSourceオブジェクトをシリアル化しようとしているために発生します。

ImageSourceオブジェクトはイメージへのパスではなく、より多くの情報を含み、XMLにシリアライズすることはできません。

はこちらをご覧ください: Serialize a System.Windows.Media.ImageSource object

関連する問題