Skip to content

fix: try more options when failed to use netfx when import clr#1791

Merged
r0x0r merged 1 commit intor0x0r:masterfrom
HZBHZB1234:master
Mar 18, 2026
Merged

fix: try more options when failed to use netfx when import clr#1791
r0x0r merged 1 commit intor0x0r:masterfrom
HZBHZB1234:master

Conversation

@HZBHZB1234
Copy link
Copy Markdown
Contributor

More information, check #1787

I have recently changes my PC and forget to install AutoPeP for vscode

@r0x0r r0x0r merged commit 73553d8 into r0x0r:master Mar 18, 2026
6 of 7 checks passed
smparkes added a commit to smparkes/pywebview that referenced this pull request Mar 30, 2026
pywebview fails to load on Windows ARM64 because pythonnet's .NET
Framework (netfx) runtime is not available on ARM64 — the clr-loader
dependency chain (NXPorts → dnlib) does not support ARM64:
pythonnet/pythonnet#2523

The upstream fallback in r0x0r#1791 successfully switches to coreclr when
netfx is unavailable, but pywebview then fails because several
components assume .NET Framework.

Use FolderBrowserDialog for the folder picker on coreclr, since the
internal FileDialogNative types (IFileDialog, FOS_PICKFOLDERS) used
by the existing OpenFolderDialog don't exist in .NET 8. On .NET
Framework, the existing FileDialogNative reflection code is preserved
unchanged, including its support for multiple folder selection.
FolderBrowserDialog does not support multi-select; this limitation
only affects coreclr users. (.NET 9 adds FolderBrowserDialog.Multiselect
which could be used in a future update.)

Update bundled WebView2 interop DLLs from Microsoft.Web.WebView2
NuGet package 1.0.2957.106 to 1.0.3240.44 (netcoreapp3.0 target):
https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.3240.44
The old DLLs referenced System.Windows.Forms.ContextMenu, which was
removed in .NET 6+:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/windows-forms/6.0/apis-throw-argumentnullexception
The new DLLs use ContextMenuStrip instead, which exists on both .NET
Framework and .NET 8, so this change is safe for all platforms.

Skip the .NET Framework registry check in _is_chromium() when running
on coreclr, since coreclr does not register in the .NET Framework
registry (HKLM\...\NDP\v4\Full). Also fix a potential UnboundLocalError
by initializing net_key before the try block and guarding CloseKey.

Add explicit clr.AddReference('Microsoft.Win32.SystemEvents') when
PYTHONNET_RUNTIME=coreclr. This assembly is auto-loaded on .NET
Framework but requires an explicit reference on coreclr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
smparkes added a commit to smparkes/pywebview that referenced this pull request Mar 30, 2026
pywebview fails to load on Windows ARM64 because pythonnet's .NET
Framework (netfx) runtime is not available on ARM64 — the clr-loader
dependency chain (NXPorts → dnlib) does not support ARM64:
pythonnet/pythonnet#2523

The upstream fallback in r0x0r#1791 successfully switches to coreclr when
netfx is unavailable, but pywebview then fails because several
components assume .NET Framework.

Use FolderBrowserDialog for the folder picker on coreclr, since the
internal FileDialogNative types (IFileDialog, FOS_PICKFOLDERS) used
by the existing OpenFolderDialog don't exist in .NET 8. On .NET
Framework, the existing FileDialogNative reflection code is preserved
unchanged, including its support for multiple folder selection.
FolderBrowserDialog does not support multi-select; this limitation
only affects coreclr users. (.NET 9 adds FolderBrowserDialog.Multiselect
which could be used in a future update.)

Update bundled WebView2 interop DLLs from Microsoft.Web.WebView2
NuGet package 1.0.2957.106 to 1.0.3240.44 (netcoreapp3.0 target):
https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.3240.44
The old DLLs referenced System.Windows.Forms.ContextMenu, which was
removed in .NET 6+:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/windows-forms/6.0/apis-throw-argumentnullexception
The new DLLs use ContextMenuStrip instead, which exists on both .NET
Framework and .NET 8, so this change is safe for all platforms.

Skip the .NET Framework registry check in _is_chromium() when running
on coreclr, since coreclr does not register in the .NET Framework
registry (HKLM\...\NDP\v4\Full). Also fix a potential UnboundLocalError
by initializing net_key before the try block and guarding CloseKey.

Add explicit clr.AddReference('Microsoft.Win32.SystemEvents') when
PYTHONNET_RUNTIME=coreclr. This assembly is auto-loaded on .NET
Framework but requires an explicit reference on coreclr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
smparkes added a commit to smparkes/pywebview that referenced this pull request Mar 30, 2026
pywebview fails to load on Windows ARM64 because pythonnet's .NET
Framework (netfx) runtime is not available on ARM64 — the clr-loader
dependency chain (NXPorts → dnlib) does not support ARM64:
pythonnet/pythonnet#2523

The upstream fallback in r0x0r#1791 successfully switches to coreclr when
netfx is unavailable, but pywebview then fails because several
components assume .NET Framework.

Use FolderBrowserDialog for the folder picker on coreclr, since the
internal FileDialogNative types (IFileDialog, FOS_PICKFOLDERS) used
by the existing OpenFolderDialog don't exist in .NET 8. On .NET
Framework, the existing FileDialogNative reflection code is preserved
unchanged, including its support for multiple folder selection.
FolderBrowserDialog does not support multi-select; this limitation
only affects coreclr users. (.NET 9 adds FolderBrowserDialog.Multiselect
which could be used in a future update.) The netfx code is wrapped in
an if/else on PYTHONNET_RUNTIME, which adds indentation; ignoring
whitespace (https://github.com/r0x0r/pywebview/compare/master...smparkes:fix/dotnet8-coreclr?expand=1&w=1)
makes the diff much simpler to review.

Update bundled WebView2 interop DLLs from Microsoft.Web.WebView2
NuGet package 1.0.2957.106 to 1.0.3240.44 (netcoreapp3.0 target):
https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.3240.44
The old DLLs referenced System.Windows.Forms.ContextMenu, which was
removed in .NET 6+:
https://learn.microsoft.com/en-us/dotnet/core/compatibility/windows-forms/6.0/apis-throw-argumentnullexception
The new DLLs use ContextMenuStrip instead, which exists on both .NET
Framework and .NET 8, so this change is safe for all platforms.

Skip the .NET Framework registry check in _is_chromium() when running
on coreclr, since coreclr does not register in the .NET Framework
registry (HKLM\...\NDP\v4\Full). Also fix a potential UnboundLocalError
by initializing net_key before the try block and guarding CloseKey.

Add explicit clr.AddReference('Microsoft.Win32.SystemEvents') when
PYTHONNET_RUNTIME=coreclr. This assembly is auto-loaded on .NET
Framework but requires an explicit reference on coreclr.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants