7

我正在构建一个使用隔离存储的 Windows Phone 7 应用程序。该代码大部分时间都有效,但我不断随机收到 IsolatedStorageExceptions:

{"An error occurred while accessing IsolatedStorage."}

There are no further details about the reason for the exception.  Here is the stack trace:

   at System.IO.IsolatedStorage.IsolatedStorageFile.DeleteFile(String file)
   at MyApp.Core.Data.WindowsPhoneFileRepository.DeleteFile(String name)
   at MyApp.Core.Domain.ThingService.SaveThing(Thing Thing)
   at MyApp.Core.Domain.TrackedThingService.PersistThingLocally(TrackedThing Thing)
   at MyApp.Ui.ViewModels.TrackViewModel.<.ctor>b__3(Thing Thing)
   at GalaSoft.MvvmLight.Command.RelayCommand`1.Execute(Object parameter)
   at GalaSoft.MvvmLight.Command.EventToCommand.Invoke(Object parameter)
   at System.Windows.Interactivity.TriggerAction.CallInvoke(Object parameter)
   at System.Windows.Interactivity.TriggerBase.InvokeActions(Object parameter)
   at System.Windows.Interactivity.EventTriggerBase.OnEvent(EventArgs eventArgs)
   at System.Windows.Interactivity.EventTriggerBase.OnEventImpl(Object sender, EventArgs eventArgs)
   at System.Windows.Controls.Primitives.ButtonBase.OnClick()
   at System.Windows.Controls.Button.OnClick()
   at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

该文件存在。我将所有的 IsolatedStorage 使用都放在 using 块中,所以我不应该在任何地方打开文件。

这可能是什么原因造成的?

如何获得有关异常原因的更多详细信息?

4

4 回答 4

7

目前不保证使用块在 WP7 中刷新/关闭流。

明确关闭所有文件/流,直到 SDK 达到您真正可以信任的程度!:)

于 2010-11-12T15:21:06.147 回答
2

我会特别检查以确保您已将所有读者和作者关闭到您尝试删除的文件中的任何内容。我并不是说这肯定会修复它,而是无法删除确实存在的文件往往是由打开的文件引起的。

于 2010-09-26T17:30:12.640 回答
0

我遇到了同样的问题。

仔细查了一下,发现有一个地方没有关闭FileStream。关闭它为我解决了这个问题。

于 2013-04-03T14:24:25.903 回答
0

不容忽视的是,WP7 仍处于 Beta 阶段(您已经从 CTP 更新到 Beta 版本对吗?)。

考虑创建一个非常简单的应用程序,以您的主应用程序的方式操作隔离存储,看看您是否可以创建问题的小型 Repo。完成后将其发送给 Microsoft,以便他们查看。

于 2010-07-17T18:24:19.543 回答