Windows phone 7 windows phone中的IsolatedStorageException
我收到一个堆栈跟踪报告,报告中说存在一个IsolatedStorageException “帧图像功能偏移量Windows phone 7 windows phone中的IsolatedStorageException,windows-phone-7,stack-trace,isolatedstorage,Windows Phone 7,Stack Trace,Isolatedstorage,我收到一个堆栈跟踪报告,报告中说存在一个IsolatedStorageException “帧图像功能偏移量 0 coredll.dll xxx_RaiseException 1 mscoree3_7.dll 2 mscoree3_7.dll 3 mscoree3_7.dll 4个转换桶 5系统.IO.IsolatedStorage.IsolatedStorage设置。保存 6系统IO隔离存储隔离存储设置清除 7 AppName.CycleManager.WriteToIsolatedStora
0 coredll.dll xxx_RaiseException
1 mscoree3_7.dll
2 mscoree3_7.dll
3 mscoree3_7.dll
4个转换桶
5系统.IO.IsolatedStorage.IsolatedStorage设置。保存
6系统IO隔离存储隔离存储设置清除
7 AppName.CycleManager.WriteToIsolatedStorage
8 AppName.SettingsPage.OnNavigatedFrom
9 Microsoft.Phone.Controls.PhoneApplicationPage.InternalOnNavigatedFrom
10系统.窗口.导航.导航服务.提升激活
11 System.Windows.Navigation.NavigationService.CompleteNavigation 12 System.Windows.Navigation.NavigationService.ContentLoader\u BeginLoad\u回调
13 System.Windows.Navigation.PageResourceContentLoader.BeginLoad\u OniThread 14.\u c\u显示类别4.\u开始加载\u b\u 0
15 mscoree3_7.dll
16 mscoree3_7.dll
17 mscoree3_7.dll
18 System.Reflection.RuntimeMethodInfo.InternalInvoke 19 System.Reflection.RuntimeMethodInfo.InternalInvoke“ 因此,我假定该异常是由WriteToIsolatedStorage()引发的 更新:
public void WriteNotesToFile()
{
if (m_noteCount > 0)
{
try
{
using (IsolatedStorageFile storagefile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (storagefile.FileExists("NotesFile"))
{
using (IsolatedStorageFileStream fileStream = storagefile.OpenFile("NotesFile", FileMode.Open, FileAccess.ReadWrite))
{
StreamWriter writer = new StreamWriter(fileStream);
for (int i = 0; i < m_noteCount; i++)
{
//writer.Write(m_arrNoteDate[i].ToShortDateString());
writer.Write(m_arrNoteDate[i].ToString("d", CultureInfo.InvariantCulture));
writer.Write(" ");
writer.Write(m_arrNoteString[i]);
writer.WriteLine("~`");
}
writer.Close();
}
}
else
{
storagefile.CreateFile("NotesFile.txt");
using (IsolatedStorageFileStream fileStream = storagefile.OpenFile("NotesFile", FileMode.Create, FileAccess.ReadWrite))
{
StreamWriter writer = new StreamWriter(fileStream);
for (int i = 0; i < m_noteCount; i++)
{
//writer.Write(m_arrNoteDate[i].ToShortDateString());
writer.Write(m_arrNoteDate[i].ToString("d", CultureInfo.InvariantCulture));
writer.Write(" ");
writer.Write(m_arrNoteString[i]);
writer.WriteLine("~`");
}
writer.Close();
}
}
}
}
catch { }
}
}
如果有人能澄清这些,我将不胜感激
谢谢,如果没有足够的空间,对的呼叫将失败。由于我们看不到
WriteXxxxToFile()
方法在做什么,它们可能正在做一些可能导致此问题的事情
这也可能与以下问题有关:您有多个线程试图访问设置或应用程序关闭或删除,但您的保存方法花费的时间太长
确定真正原因的最佳方法是添加一些处理,以支持调用WriteToIsolatedStorage()
引发此类异常,然后根据您的应用/需要记录并报告该异常的情况
关于删除
,请参见
“此方法将不可撤销地删除
当前用户的应用程序及其所有目录和文件。“
嗨,你能提供异常消息吗?@Ashura有趣的是我无法重现崩溃(我不知道抛出了什么消息。谢谢@Matt,我已经用writeNotofile函数更新了问题。这个报告是在我更新了版本后才出现的,几乎没有什么变化。它以前从未出现过。奇怪的是,对于更新,写入/读取的逻辑从未被修改过。因为你正在抑制来自
Wr的任何错误iteNoteToFile
方法它将不存在。我建议添加适当的错误日志和异常处理,并提交更新。
public void WriteNotesToFile()
{
if (m_noteCount > 0)
{
try
{
using (IsolatedStorageFile storagefile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (storagefile.FileExists("NotesFile"))
{
using (IsolatedStorageFileStream fileStream = storagefile.OpenFile("NotesFile", FileMode.Open, FileAccess.ReadWrite))
{
StreamWriter writer = new StreamWriter(fileStream);
for (int i = 0; i < m_noteCount; i++)
{
//writer.Write(m_arrNoteDate[i].ToShortDateString());
writer.Write(m_arrNoteDate[i].ToString("d", CultureInfo.InvariantCulture));
writer.Write(" ");
writer.Write(m_arrNoteString[i]);
writer.WriteLine("~`");
}
writer.Close();
}
}
else
{
storagefile.CreateFile("NotesFile.txt");
using (IsolatedStorageFileStream fileStream = storagefile.OpenFile("NotesFile", FileMode.Create, FileAccess.ReadWrite))
{
StreamWriter writer = new StreamWriter(fileStream);
for (int i = 0; i < m_noteCount; i++)
{
//writer.Write(m_arrNoteDate[i].ToShortDateString());
writer.Write(m_arrNoteDate[i].ToString("d", CultureInfo.InvariantCulture));
writer.Write(" ");
writer.Write(m_arrNoteString[i]);
writer.WriteLine("~`");
}
writer.Close();
}
}
}
}
catch { }
}
}
IsolatedStorageFile storagefile = IsolatedStorageFile.GetUserStoreForApplication();
storagefile.Remove();