The following code seems to occasionally produce this stacktrace. It looks like it is happening within the framework when the dispose method is called on the internal FileStream
object? Seems like a bug to me, any ideas?
下面的代码似乎偶尔会产生这种堆栈跟踪。当在内部文件流对象上调用dispose方法时,看起来它正在框架中发生?对我来说似乎是一个bug,有什么想法吗?
var previousVersion = long.Parse(File.ReadAllText(Paths.VersionFile));
StackTrace:
加:
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
EDIT VersionFile
path is grabbed this way:
编辑VersionFile路径的方法是:
public static string VersionFile {
get {
var path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
return Path.Combine(path, "version.dat");
}
}
1 个解决方案
#1
0
If I had to guess, I think you might be running into a race condition due to the implicit Flush()
that occurs during disposal of the under-the-hood FileStream
in that ReadAllText
call.
如果我不得不猜测,我认为您可能遇到了竞态条件,这是由于在ReadAllText调用中处理底层文件流时发生的隐式Flush()。
(caveat: not in front of mono sources, so can't confirm exact behavior)
(注意:不是在mono资源的前面,所以不能确定确切的行为)
Is it possible that:
有可能:
- You are replacing/reopening/etc. the same file path in another thread?
- 你正在取代/重启/等。另一个线程中的相同文件路径?
- Deleting that path immediately after or in another thread?
- 在另一个线程之后或在另一个线程中删除该路径?
- Otherwise losing access to the checked path? (file share unmounting?)
- 否则将失去对已检查路径的访问?(文件共享卸载吗?)
#1
0
If I had to guess, I think you might be running into a race condition due to the implicit Flush()
that occurs during disposal of the under-the-hood FileStream
in that ReadAllText
call.
如果我不得不猜测,我认为您可能遇到了竞态条件,这是由于在ReadAllText调用中处理底层文件流时发生的隐式Flush()。
(caveat: not in front of mono sources, so can't confirm exact behavior)
(注意:不是在mono资源的前面,所以不能确定确切的行为)
Is it possible that:
有可能:
- You are replacing/reopening/etc. the same file path in another thread?
- 你正在取代/重启/等。另一个线程中的相同文件路径?
- Deleting that path immediately after or in another thread?
- 在另一个线程之后或在另一个线程中删除该路径?
- Otherwise losing access to the checked path? (file share unmounting?)
- 否则将失去对已检查路径的访问?(文件共享卸载吗?)