以下代码似乎偶尔会产生这种堆栈跟踪。在内部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");
}
}
答案 0 :(得分:0)
如果我不得不猜测,我认为你可能会遇到竞争条件,因为在Flush()
处理引擎盖FileStream
期间发生隐式ReadAllText
打电话。
(警告:不在单声道源之前,因此无法确认确切的行为)
是否有可能: