brianzhouzc / RocketBot

An automated Pokémon Go Bot
GNU General Public License v3.0
564 stars 316 forks source link

Error Writing to log. #543

Open unoriginal-one opened 7 years ago

unoriginal-one commented 7 years ago

[08:57:52 AM] System.AggregateException: One or more errors occurred. ---> System.IO.IOException: The process cannot access the file 'C:\Users\kcadmin\Desktop\PokeBot\Logs.txt' because it is being used by another process. at System.IO.Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding) at System.IO.File.AppendAllText(String path, String contents) at PokemonGo.RocketAPI.Client.ColoredConsoleWrite(ConsoleColor color, String text) in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 252 at PokemonGo.RocketAPI.Client.d__19.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 225 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.get_Result() at PokemonGo.RocketAPI.Client.d13.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 66 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at PokemonGo.RocketAPI.Window.MainForm.d24.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Window\MainForm.cs:line 385 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at PokemonGo.RocketAPI.Window.MainForm.d25.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Window\MainForm.cs:line 499 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at PokemonGo.RocketAPI.Window.MainForm.d22.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Window\MainForm.cs:line 293 ---> (Inner Exception #0) System.IO.IOException: The process cannot access the file 'C:\Users\kcadmin\Desktop\PokeBot\Logs.txt' because it is being used by another process. at System.IO.Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost) at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding) at System.IO.File.InternalAppendAllText(String path, String contents, Encoding encoding) at System.IO.File.AppendAllText(String path, String contents) at PokemonGo.RocketAPI.Client.ColoredConsoleWrite(ConsoleColor color, String text) in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 252 at PokemonGo.RocketAPI.Client.d__19.MoveNext() in C:\development\workspace\Pokemon-Go-Rocket-API\PokemonGo\RocketAPI\Client.cs:line 225<---

trentonwallace commented 7 years ago

make sure, C:\Users\kcadmin\Desktop\PokeBot\Logs.txt is not open or being used while the program is running. restart your computer if nothing else.

unoriginal-one commented 7 years ago

It was not open by anything else. That was after 33 min of the bot running. The bot did recover automatically and is running again though.

trentonwallace commented 7 years ago

there is a few places, at least three in Client.cs and MainForm.cs that use File.AppendAllText

probably just need to use a stream or check to make sure it's not in use.