RWELabs / Stardew-Valley-Mod-Manager

[Passion Project] The Stardew Valley Mod Manager is a powerful tool that is designed to be used alongside SMAPI to help you install and manage mods, automatically install modpacks and manage your game saves.
Other
29 stars 1 forks source link

[Issue] Stardew Valley WebTools crashes on Startup #111

Closed RyanWalpole closed 1 year ago

RyanWalpole commented 1 year ago

The Issue or Bug

The Stardew Valley WebTools UI loads a blank window and then has an unhandled exception

Version

221001

Operating System

Windows 11

Steps to reproduce the behavior

  1. Open Stardew Valley Mod Manager
  2. Open WebTools
  3. Observe error

Log Files

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

************** Exception Text **************
System.Runtime.InteropServices.COMException (0x800700AA): The requested resource is in use. (Exception from HRESULT: 0x800700AA)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateCoreWebView2ControllerAsync>d__72.MoveNext()
--- 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.ValidateEnd(Task task)
   at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__23.MoveNext()
--- 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 Stardew_Mod_Manager.Forms.Webapp.WebToolsHome.<InitializeAsync>d__7.MoveNext() in C:\Users\rwalpole\Documents\GitHub\Stardew-Valley-Mod-Framework\source-code\Mod Manager (Facelift Development)\Stardew Mod Manager\Forms\Webapp\WebToolsHome.cs:line 108
--- 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 Stardew_Mod_Manager.Forms.Webapp.WebToolsHome.<WebToolsHome_Load>d__6.MoveNext() in C:\Users\rwalpole\Documents\GitHub\Stardew-Valley-Mod-Framework\source-code\Mod Manager (Facelift Development)\Stardew Mod Manager\Forms\Webapp\WebToolsHome.cs:line 101
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<>c.<ThrowAsync>b__6_0(Object state)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4515.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Stardew Mod Manager
    Assembly Version: 22.9.0.2
    Win32 Version: 22.09.00.02
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Stardew%20Mod%20Manager.exe
----------------------------------------
Syncfusion.Licensing
    Assembly Version: 19.4460.0.56
    Win32 Version: 19.4460.0.56
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Syncfusion.Licensing.DLL
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4536.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.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4550.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.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4395.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Syncfusion.Shared.Base
    Assembly Version: 19.4460.0.56
    Win32 Version: 19.4460.0.56
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Syncfusion.Shared.Base.DLL
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4341.0 built by: NET48REL1LAST_C
    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.4566.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.4161.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.4161.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll
----------------------------------------
Syncfusion.Tools.Windows
    Assembly Version: 19.4460.0.56
    Win32 Version: 19.4460.0.56
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Syncfusion.Tools.Windows.DLL
----------------------------------------
Syncfusion.Core.WinForms
    Assembly Version: 19.4460.0.56
    Win32 Version: 19.4460.0.56
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Syncfusion.Core.WinForms.DLL
----------------------------------------
Syncfusion.Grid.Windows
    Assembly Version: 19.4460.0.56
    Win32 Version: 19.4460.0.56
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Syncfusion.Grid.Windows.DLL
----------------------------------------
Microsoft.Web.WebView2.WinForms
    Assembly Version: 1.0.1293.44
    Win32 Version: 1.0.1293.44
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Microsoft.Web.WebView2.WinForms.DLL
----------------------------------------
Microsoft.Web.WebView2.Core
    Assembly Version: 1.0.1293.44
    Win32 Version: 1.0.1293.44
    CodeBase: file:///C:/Program%20Files%20(x86)/RWE%20Labs/Stardew%20Valley%20Mod%20Manager/Microsoft.Web.WebView2.Core.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:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

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.

Screenshots

image

Additional Context

No response

Suggested Resolution

No response

RyanWalpole commented 1 year ago

Fix did not actually fix anything. Might be that the WebView2 cannot generate user data folders being in the program files folder? This could be a permissions issue. Going to try the following:

Proposed Resolution

public Example()
        {
            InitializeComponent();
            InitializeBrowser();
        }
        private async Task InitializeBrowser()
        {
            var userDataFolder = 
            Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\RWE Labs\SDVMM\WV2\";
            var env = await CoreWebView2Environment.CreateAsync(null, userDataFolder);
            await webView.EnsureCoreWebView2Async(env);
            webView.Source = new Uri("https://example.com") ;
        }
RyanWalpole commented 1 year ago

Fix did not actually fix anything. Might be that the WebView2 cannot generate user data folders being in the program files folder? This could be a permissions issue. Going to try the following:

Proposed Resolution

public Example()
        {
            InitializeComponent();
            InitializeBrowser();
        }
        private async Task InitializeBrowser()
        {
            var userDataFolder = 
            Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\RWE Labs\SDVMM\WV2\";
            var env = await CoreWebView2Environment.CreateAsync(null, userDataFolder);
            await webView.EnsureCoreWebView2Async(env);
            webView.Source = new Uri("https://example.com") ;
        }

Didn't actually finish comment. The proposed solution is to asynchronously create a new user data folder in the appdata where it should be accessible and read/writeable no matter what.