medallyon / eso-discord-status

Sync your semi-live variables from your ESO client to your Discord Status using Rich Presence.
https://www.esoui.com/downloads/info2054-DiscordStatusUpdater.html
GNU Affero General Public License v3.0
12 stars 3 forks source link

Exception: Access to the path 'DiscordStatusClient.exe' is denied. #39

Closed AngelusMortiel closed 2 years ago

AngelusMortiel commented 2 years ago

The last known good version was 0.4.4.

I try to run 0.4.7 and receive an unhandled exception error "Access to the path 'DiscordStatusClient.exe' is denied.", after which all files are purged from the DiscordStatus add-on folder except the client executable itself.

Below is the exception details, if it helps.

See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box.

** Exception Text ** System.UnauthorizedAccessException: Access to the path 'DiscordStatusClient.exe' is denied. at System.IO.Directory.DeleteHelper(String fullPath, String userPath, Boolean recursive, Boolean throwOnTopLevelDirectoryNotFound, WIN32_FIND_DATA& data) at System.IO.Directory.Delete(String fullPath, String userPath, Boolean recursive, Boolean checkHost) at ESO_Discord_RichPresence_Client.Main.InstallAddon() at ESO_Discord_RichPresence_Client.SavedVariables.EnsureSavedVarsExist() at ESO_Discord_RichPresence_Client.SavedVariables.Initialise() at ESO_Discord_RichPresence_Client.Main.Main_Load(Object sender, EventArgs e) at System.Windows.Forms.Form.OnLoad(EventArgs e) at System.Windows.Forms.Form.OnCreateControl() at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) at System.Windows.Forms.Control.CreateControl() at System.Windows.Forms.Control.WmShowWindow(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WmShowWindow(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

** Loaded Assemblies ** mscorlib Assembly Version: 4.0.0.0 Win32 Version: 4.8.4420.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll

DiscordStatusClient Assembly Version: 1.0.0.0 Win32 Version: 1.0.0.0 CodeBase: file:///C:/Users/Morti/OneDrive/Documents/Elder%20Scrolls%20Online/live/AddOns/DiscordStatus/Client/DiscordStatusClient.exe

System.Windows.Forms Assembly Version: 4.0.0.0 Win32 Version: 4.8.4400.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

System Assembly Version: 4.0.0.0 Win32 Version: 4.8.4360.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll

System.Drawing Assembly Version: 4.0.0.0 Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

System.Configuration Assembly Version: 4.0.0.0 Win32 Version: 4.8.4190.0 built by: NET48REL1LAST_B CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

System.Core Assembly Version: 4.0.0.0 Win32 Version: 4.8.4455.0 built by: NET48REL1LAST_C CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll

System.Xml Assembly Version: 4.0.0.0 Win32 Version: 4.8.4084.0 built by: NET48REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll

Accessibility Assembly Version: 4.0.0.0 Win32 Version: 4.8.4084.0 built by: NET48REL1 CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll

** JIT Debugging ** To enable just-in-time (JIT) debugging, the .config file for this application or computer (machine.config) must have the jitDebugging value set in the system.windows.forms section. The application must also be compiled with debugging enabled.

For example:

When JIT debugging is enabled, any unhandled exception will be sent to the JIT debugger registered on the computer rather than be handled by this dialog box.

medallyon commented 2 years ago

Thanks, I already submitted a new version with a fix to ESOUI that should be accepted soon. You can also download the latest release manually if you don't want to wait.

medallyon commented 2 years ago

It appears that this issue persists. I need to do some more testing to figure out what causes it.

In the meantime, @whisperity any clue what's going on here? In previous releases, I learned that not providing the DiscordStatus.exe.config file causes this error, but that's been remedied in the latest release. It seems to raise the error at InstallAddon() now.

medallyon commented 2 years ago

One fix I've observed for this issue is to move the Client folder somewhere else, such as your Desktop. Sorry for the inconvenience.

whisperity commented 2 years ago

System.UnauthorizedAccessException: Access to the path 'DiscordStatusClient.exe' is denied.

Please confirm, but is DiscordStatusClient.exe the name of the program that runs ESO_Discord_RichPresence_Client.Main?

move the Client

@Medallyon If the move is indeed a fix, then it should be a simple permission error. It's been a long while since I used Windows (and C# for that matter), but there is a crucial distinction between how files are handled on Windows as opposed to how they are handled on more POSIX-friendly operating systems like Linux.

The addon binary is trying to replace itself. And it can't, because of the fact that the addon binary is running (the .exe is currently loaded into memory), there is an implicit lock on the file -- it can't be written, or renamed, or deleted, whatsoever. Conversely, on Linux, when you open a binary (or any file, really!), the running process will only hard link the content in the memory. But you can delete even binaries currently running... the actual data from the disk won't actually be deleted until the last hard link dies... But if you replace, let's say /bin/medallyon with a new binary, subsequent processes will run that, while old ones still running the old binary will keep it alive. Not on Windows... the file path of the command is sacrosanct, and until every process that had opened a handle (I think that's the Windows terminology) to that file entry shut down, it can't be meddled with...

(I often run into the same issue when working on papers on Windows -- if I open a rendered PDF in a PDF viewer, it will have the file open and thus write-locked. And then the document compiler (LaTeX) cannot create a new PDF, even if I change contents and click "Compile" again.)

This is why you conventionally see things like "Mozilla Firefox Update" being its own .exe, sometimes even running as a system service... I think even Steam has its own dedicated "update" binary (even if temporarily!) when the application image is updated, and not just packaged content.

medallyon commented 2 years ago

Please confirm, but is DiscordStatusClient.exe the name of the program that runs ESO_Discord_RichPresence_Client.Main?

Yes it is, actually.

It does get rid of the whole DiscordStatus directory, including the addon files one directory up. I don't know why it would be attempting to replace itself. I'm having trouble trying to debug this because of the inherently different locations of the Debug binary when debugging from Visual Studio, and the binary that's part of the ESO/AddOns folder.

It'd be great if there was a way for me to debug the client FROM the ESO/AddOns folder, but I have no idea how to do that.

medallyon commented 2 years ago

I figured out that I can change the output directory in the Project Settings in order to debug the current configuration. This way I was able to identify the underlying issue, which was that the Client was attempting to update the Addon files to the latest version by deleting the parent directory. It now replaces the corresponding files appropriately with Release 1.0.1.