I'm encountering a very strange bug which appears only when compiling in Release mode, while in Debug mode the code runs perfectly. Moreover, the bug is encountered only in one machine (a user reported this).
This is the stack trace:
System.IO.FileNotFoundException: Unable to find file 'C:\Users...\FileName.txt'. File name: 'C:\Users...\FileName.txt' in System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) in System.IO.FileInfo.get_Length() in PatcherNET4.FileHandler.LocalFile.get_Size() in PatcherNET4.FileHandler.CachedFile.IsLocalValid(LocalFile file) in PatcherNET4.FileHandler.FileManager.<>c__DisplayClassd.b__9(CachedFile file) in System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable
1 source, Func
2 predicate) in PatcherNET4.FileHandler.FileManager.RemoveLocalFiles() in PatcherNET4.FileHandler.FileManager.DownloadMissingFiles() in System.Threading.ThreadHelper.ThreadStart_Context(Object state) in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) in System.Threading.ThreadHelper.ThreadStart()
And this is the code:
// CachedFile
...
public bool IsLocalValid(LocalFile file)
{
var checkName = file.Name == Name;
var checkSize = file.Size == Size;
var checkLastWrite = file.LastWriteTime == LastWriteTime;
return checkName && checkSize && checkLastWrite;
}
...
//LocalFile
...
public uint Size
{
get
{
_info.Refresh();
return (uint)_info.Length;
}
}
...
How is this possible? I can assure you that there is no difference in the interested pieces of code between the release and debug mode. I don't really know what to do, this is probably the strangest bug I've ever seen.