6
以下代碼似乎偶爾會產生此堆棧跟蹤。它看起來像在內部FileStream
對象上調用dispose方法時發生在框架內?看起來像一個錯誤,對我來說,有什麼想法?MonoTouch File.ReadAllText拋出內部FileStream.Dispose異常()
var previousVersion = long.Parse(File.ReadAllText(Paths.VersionFile));
堆棧跟蹤:
System.IO.IOException: Invalid parameter
at System.IO.FileStream.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
at System.IO.Stream.Close() [0x00000] in <filename unknown>:0
at System.IO.StreamReader.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
at System.IO.TextReader.Dispose() [0x00000] in <filename unknown>:0
at System.IO.File.ReadAllText (System.String path) [0x00000] in <filename unknown>:0
at CatalystHD.Shared.BaseLoginController.CheckIfFirstRunThisVersion() [0x00000] in <filename unknown>:0
at CatalystHD.Shared.BaseLoginController.ViewDidLoad() [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIViewController.get_View() [0x00000] in <filename unknown>:0
at CatalystHD.IPad.RootViewController.AnimateTo (MonoTouch.UIKit.UIViewController aController, UIViewAnimationTransition transition) [0x00000] in <filename unknown>:0
at CatalystHD.IPad.RootViewController.Logout (Boolean timeout) [0x00000] in <filename unknown>:0
at CatalystHD.IPad.NotebookSelectionController.logoutButton_Clicked (System.Object sender, System.EventArgs e) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIBarButtonItem Callback.Call (MonoTouch.Foundation.NSObject sender) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in <filename unknown>:0
at CatalystHD.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0
編輯 VersionFile
路徑抓住這樣:
public static string VersionFile {
get {
var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
return Path.Combine(path, "version.dat");
}
}
什麼是傳遞與'Paths.VersionFile'? – 2012-03-06 18:29:59
@ DanielA.White查看編輯 – 2012-03-06 18:35:07
我們需要更多關於您應用程序的上下文,例如,我可以在沒有任何問題的情況下在循環中運行代碼10000x,因爲其他內容必須有所不同。像什麼時候該文件創建,更新,刪除?由任何不同的線程?它發生在設備,模擬器上嗎? ...和所有版本號。 – poupou 2012-03-06 19:16:49