dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.37k stars 4.75k forks source link

NativeAOT: ilc compilation failure against Interop+Kernel32.GetProcAddress #69026

Closed hez2010 closed 2 years ago

hez2010 commented 2 years ago

Found while compiling a Winforms app with NativeAOT.

ILC: Method '[Microsoft.Win32.SystemEvents]Interop+Kernel32.GetProcAddress(native int,string)' will always throw beca
  use: Failed to load type 'System.Runtime.InteropServices.AnsiStringMarshaller' from assembly 'System.Runtime.InteropS
  ervices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

This is causing winforms app crashing on exit.

Version: 7.0.0-preview.5.22257.1

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/interop-contrib See info in area-owners.md if you want to be subscribed.

Issue Details
Found while compiling Winforms with NativeAOT. ``` ILC: Method '[Microsoft.Win32.SystemEvents]Interop+Kernel32.GetProcAddress(native int,string)' will always throw beca use: Failed to load type 'System.Runtime.InteropServices.AnsiStringMarshaller' from assembly 'System.Runtime.InteropS ervices, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ``` Version: 7.0.0-preview.5.22257.1
Author: hez2010
Assignees: -
Labels: `area-System.Runtime.InteropServices`, `untriaged`
Milestone: -
jkotas commented 2 years ago

This is same problem as https://github.com/dotnet/runtime/issues/69001#issuecomment-1120141177 . It will fix itself once the AnsiStringMarshaller namespace change flows through the system.