ShareMediaTask仅在调试模式下工作

时间:2014-04-03 17:17:26

标签: c# windows-phone-8 visual-studio-debugging

通常情况下,在调试至少2天之前,我倾向于不在StackOverflow上询问。但这次,调试它是不可能的。所以这就是我想要实现的目标:

  • 用户按下快门按钮并拍摄照片。
  • 该应用进入第二个屏幕,启用用户后处理图像,保存到图像库,使用ShareMediaTask与朋友分享

所以使用这段代码:

MediaLibrary library = new MediaLibrary();
if (pic == null)
{
    using (MemoryStream saveStream = new MemoryStream(imagedata))
    {
        saveStream.Seek(0, SeekOrigin.Begin);
        pic = library.SavePicture("camera.NET_image_" + System.Environment.TickCount, saveStream);
        saveStream.Close();
    }
}
ShareMediaTask shareMediaTask = new ShareMediaTask();
shareMediaTask.FilePath = pic.GetPath();
shareMediaTask.Show();

正如您所看到的,如果图片已经完成(通过使用保存按钮),图片将保存到图片中心。保存工作正常。所以我不明白为什么它不处于调试模式时崩溃,并在调试模式下正常工作。

我唯一的提示就是在启动sharetask时抛出了一个激活(但共享任务仍然有效,我的朋友确实已经确认他已经收到了所有图片。

对于有很多时间的人来说,这是不可思议的(至少对我而言我声称不是一个完整的c#noob)长堆栈跟踪:

at System.IO.__Error.StreamIsClosed()
at System.IO.MemoryStream.get_Position()
at WriteMemoryStreamToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
at System.Runtime.Serialization.ClassDataContract.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.SerializeAndVerifyType(DataContract dataContract, XmlWriterDelegator xmlWriter, Object obj, Boolean verifyKnownType, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.SerializeWithXsiType(XmlWriterDelegator xmlWriter, Object obj, RuntimeTypeHandle objectTypeHandle, Type objectType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle, Type declaredType)
at System.Runtime.Serialization.XmlObjectSerializerWriteContext.InternalSerialize(XmlWriterDelegator xmlWriter, Object obj, Boolean isDeclaredType, Boolean writeXsiType, Int32 declaredTypeID, RuntimeTypeHandle declaredTypeHandle)
at WriteKeyValueOfstringanyTypeToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , ClassDataContract )
at System.Runtime.Serialization.ClassDataContract.WriteXmlValue(XmlWriterDelegator xmlWriter, Object obj, XmlObjectSerializerWriteContext context)
at WriteArrayOfKeyValueOfstringanyTypeToXml(XmlWriterDelegator , Object , XmlObjectSerializerWriteContext , CollectionDataContract )
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, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.DataContractSerializer.InternalWriteObject(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObjectHandleExceptions(XmlWriterDelegator writer, Object graph, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(XmlDictionaryWriter writer, Object graph)
at System.Runtime.Serialization.XmlObjectSerializer.WriteObject(Stream stream, Object graph)
at Microsoft.Phone.Shell.BaseStreamPersister.Serialize(IDictionary`2 dictionary, IEnumerable`1 knownTypes)
at Microsoft.Phone.Shell.PhoneApplicationService.SaveState()
at Microsoft.Phone.Shell.PhoneApplicationService.FireDeactivated(UInt32 reason)
at Microsoft.Phone.TaskModel.Interop.ITask.Pause.Invoke(UInt32 reason)
at Microsoft.Phone.TaskModel.Interop.Task.FireOnPause(UInt32 reason)

虽然听起来很容易理解,有一个无法访问的流,但是有人可以告诉我他们的流是什么类型的流吗?因为至少在我的用户代码中,除了保存图像之外没有任何流水线工作(并且成功,就像我在图片中心看到的那样容易)

0 个答案:

没有答案