Skip to content

NETFX 4.8.1: Arm64 compiled WPF applications attempt to load x64 wpfgfx_v0400.dll #6032

@snickler

Description

@snickler
  • .NET Core Version: N/A
  • Windows version: Windows 11 22543.1000 Arm64
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes. 4.8.9014.0
  • Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? No
  • Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.

Problem description:
Creating a blank WPF application targeting .NET Framework 4.8 and compiled for Arm64 will crash when loading the WpfGfx native library.

Actual behavior:

The NativeWPFDLLLoader in PresentationCore.dll incorrectly tries to load the wpfgfx_v0400.dll from Framework64 instead of FrameworkArm64.

Stack Trace from debugging in dnSpy
{System.DllNotFoundException: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\wpfgfx_v0400.dll ---> System.ComponentModel.Win32Exception: %1 is not a valid Win32 application
   --- End of inner exception stack trace ---
   at MS.Internal.NativeWPFDLLLoader.LoadNativeWPFDLL(UInt16* relDllPath, UInt16* baseDllPath)
   at MS.Internal.NativeWPFDLLLoader.LoadCommonDLLsAndDwrite()
   at CModuleInitialize.{ctor}(CModuleInitialize* , IntPtr cleaningUpFunc)
   at ?A0xe5657cc7.InitCmiStartupRunner()
   at ?A0xe5657cc7.??__E?A0xe5657cc7@unused@@YMXXZ()
   at _initterm_m((fnptr)* pfbegin, (fnptr)* pfend)
   at <CrtImplementationDetails>.LanguageSupport.InitializePerAppDomain(LanguageSupport* )
   at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
   at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )}
Stack Trace from debugging in VS 2022
'WpfApp1.exe' (Win32): Loaded 'C:\Users\jerem\source\repos\WpfApp1\WpfApp1\bin\Debug\WpfApp1.exe'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\mscoree.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'. 
The thread 0x4254 has exited with code 0 (0x0).
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\FrameworkArm64\v4.0.30319\mscoreei.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\shlwapi.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\kernel.appcore.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\version.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\FrameworkArm64\v4.0.30319\clr.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\user32.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\win32u.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\gdi32.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140_clr0400.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\gdi32full.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase_clr0400.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\msvcp_win.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\imm32.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. 
'WpfApp1.exe' (Win32): Unloaded 'C:\Windows\System32\combase.dll'
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\psapi.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\mscorlib\4dffdcc6cf279e4492a61d32b5e6aa1f\mscorlib.ni.dll'. 
'WpfApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_ARM64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\ole32.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\combase.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\bcryptprimitives.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\uxtheme.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\System\8ddd8f2f6cbf456f5587b49bb9f6b266\System.ni.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\WpfApp1\7779bee82bc15d021758dc3d49204f91\WpfApp1.ni.exe'. 
'WpfApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Users\jerem\source\repos\WpfApp1\WpfApp1\bin\Debug\WpfApp1.exe'. Symbols loaded.
'WpfApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\System.Core\690159aace5f01042431a7e46d66a993\System.Core.ni.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\WindowsBase\275f554bfad70b847a9a483b60b48b2b\WindowsBase.ni.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\cryptsp.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\rsaenh.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\cryptbase.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\PresentationCore\076f5a832c6e2728092fd7baccf62210\PresentationCore.ni.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\Presentatio5ae0f00f#\29216d2b932a993ddfae1f43e21cfe38\PresentationFramework.ni.dll'. 
'WpfApp1.exe' (CLR v4.0.30319: WpfApp1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (CLR v4.0.30319: WpfApp1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (CLR v4.0.30319: WpfApp1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (CLR v4.0.30319: WpfApp1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_ARM64\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_ARM64\System.Xaml\2d301309c3d2584402ecaba90c76b74d\System.Xaml.ni.dll'. 
'WpfApp1.exe' (CLR v4.0.30319: WpfApp1.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\FrameworkArm64\v4.0.30319\clrjit.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\System32\DWrite.dll'. 
'WpfApp1.exe' (Win32): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\wpfgfx_v0400.dll'. 
'WpfApp1.exe' (Win32): Unloaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\WPF\wpfgfx_v0400.dll'
Exception thrown at 0x00007FFD0B49CA44 in WpfApp1.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
Exception thrown at 0x00007FFD0B49CA44 in WpfApp1.exe: Microsoft C++ exception: [rethrow] at memory location 0x0000000000000000.
An unhandled exception of type 'System.TypeInitializationException' occurred in Unknown Module.
The type initializer for '<Module>' threw an exception.


Expected behavior:

The Native Arm64 WPF Libraries should be loaded when the process architecture is Arm64.

Minimal repro:

  1. Create a blank WPF (.NET Framework) application in Visual Studio 2022 (probably even 2019)
  2. Edit .csproj to change Platform to arm64, or manually build project with msbuild and set /platform:arm64.
  3. Run generated executable on an Arm64 device and reproduce crash behavior.

Metadata

Metadata

Assignees

Labels

InvestigateRequires further investigation by the WPF team.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions