TShock unable to write to ServerLog.txt on launch
TShock version: 1.4.4.8.1 TShock build number (if known): Current public release
Description of isssue: For some reason, since the coding switch happened for the 1.4.4 release, I've been having troubles with TShock being unable to run due to having issues trying to write/create ServerLog.txt in the install directory. I've made an exception in my AV, I've ran as Admin, I've ran in compatibility mode, but nothing works. I end up needing to use Windows 10's Troubleshooter to get it to run. Initially, the OS tries to use the Windows 8 Compatibility, crash occurs, tell it to move on, changes to Win 7 + Admin Privileges, then it magically runs. I have to do this EVERY time I relaunch TShock.
OS: Windows 10 (x64) UAC: Admin Account AV: AVG
Reproduction steps (if applicable)?
- Upgrade install/Fresh install (both work, no plugins)
- Attempt to launch TShock from TShock.Server.exe
- Wait a few seconds.
- TShock throws the error.
Fatal startup exception. Could not write to "ServerLog.txt". Exception details:
System.UnauthorizedAccessException: Access to the path 'C:\Users\xxxx\Desktop\TShock\ServerLog.txt' is denied.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path, Boolean append)
at TerrariaApi.Server.ServerLogWriter..ctor(String logFilePath) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/ServerLogWriter.cs:line 19
Unhandled exception
System.UnhandledExceptionEventArgs
Unhandled exception. System.TypeInitializationException: The type initializer for 'TerrariaApi.Server.ServerApi' threw an exception.
---> System.UnauthorizedAccessException: Access to the path 'C:\Users\Sprite\Desktop\TShock\ServerLog.txt' is denied.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
at System.IO.Strategies.FileStreamHelpers.ChooseStrategy(FileStream fileStream, String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
at System.IO.StreamWriter..ctor(String path, Boolean append)
at TerrariaApi.Server.ServerLogWriter..ctor(String logFilePath) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/ServerLogWriter.cs:line 19
at TerrariaApi.Server.LogWriterManager..ctor(Boolean enabled) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/LogWriterManager.cs:line 31
at TerrariaApi.Server.ServerApi..cctor() in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/ServerApi.cs:line 72
--- End of inner exception stack trace ---
at TerrariaApi.Server.ServerApi.get_LogWriter() in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/TerrariaApi.Server/ServerApi.cs:line 51
at TerrariaApi.Reporting.CrashReporter.CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e) in /home/runner/work/TShock/TShock/TerrariaServerAPI/TerrariaServerAPI/Reporting/CrashReporter.cs:line 36
Do not put TShock on your desktop: Windows does not like it. Put it somewhere such as: C:/TShock/*
Do not put TShock on your desktop: Windows does not like it. Put it somewhere such as:
C:/TShock/*
I've always had TShock on my Desktop. Previous to the coding switch, I never had any issues with TShock doing this.
There were already users reporting the issue on TShock 4. It is unlikely an issue on our side or on TShock 5. It's possible you changed a Windows setting to allow TerrariaServer.exe, but not TShock.Server.exe. However, it's hard to say for sure.
There were already users reporting the issue on TShock 4. It is unlikely an issue on our side or on TShock 5. It's possible you changed a Windows setting to allow TerrariaServer.exe, but not TShock.Server.exe. However, it's hard to say for sure.
Nope, I haven't tinkered with my OS's settings at all. The most I've done is run compatibility mode, and run as Admin.