[release/5.0] P/Invoke function returning SafeSocketHandle throws MissingMethodException (#45911)#45942
Conversation
…ption (dotnet#45911) * P/Invoke function returning SafeSocketHandle throws MissingMethodException The ILLinker is trimming the private default constructors of SafeHandle classes if they are not used by the library. Adding an XML descriptor file to preserve the private constructors of these SafeHandles so they can be used in P/Invokes in external code. Fix dotnet#45633 Suppress P/Invoke test on Browser
|
Tagging subscribers to this area: @dotnet/ncl Issue DetailsDescriptionThe ILLinker is trimming the private default constructors of SafeHandle classes if they are not used by the library. Adding an XML descriptor file to preserve the private constructors of these SafeHandles so they can be used in P/Invokes in external code. Customer ImpactIf an app is using SafeSocketHandle as the return of a P/Invoke and upgrades from 3.1 to 5.0, the app is broken with TestingAdded 2 new tests for the SafeHandles identified as problematic to ensure customers can P/Invoke using these classes. RiskLow Fix #45633
|
jeffschwMSFT
left a comment
There was a problem hiding this comment.
Approved. We should consider this for 5.0.2
|
This is broken in the release/5.0 branch because of some build infrastructure differences between master and release/5.0. (Thank you, tests!) Working on a fix. |
…astructure expects them.
|
The single test failure is #43981. |
Description
The ILLinker is trimming the private default constructors of SafeHandle classes if they are not used by the library. Adding an XML descriptor file to preserve the private constructors of these SafeHandles so they can be used in P/Invokes in external code.
Customer Impact
If an app is using SafeSocketHandle as the return of a P/Invoke and upgrades from 3.1 to 5.0, the app is broken with
System.MissingMethodException: .ctor. There isn't a workaround other than not usingSafeSocketHandlein the P/Invoke signature.Testing
Added 2 new tests for the SafeHandles identified as problematic to ensure customers can P/Invoke using these classes.
Risk
Low
Fix #45633