CsWinRT
CsWinRT copied to clipboard
Bug: MarshalInspectable.CreateMarshaler exhibits different behaviors and results in UWP and WinUI 3
Description
MarshalInspectable.CreateMarshaler exhibits different behaviors and results in UWP and WinUI 3
------------------------------------------
MarshalInspectable.CreateMarshaler 在 UWP 和 WinUI 3 中表现出不同的行为和结果
Steps To Reproduce
- Create WinUI 3 and UWP blank projects, the configuration used by the project: .NET 9 rc 2, CsWinRT 2.1.6, Windows App SDK 1.6.240923002
- After the application is initialized, add the following code:
TypedEventHandler<CoreWindow, object> windowPositionChangedEventHandler = new(OnWindowPositionChanged);
IObjectReference objectReference = MarshalInterface<TypedEventHandler<CoreWindow,object>>.CreateMarshaler(windowPositionChangedEventHandler);
- An exception occurred in UWP and the WinUI 3 project executed smoothly.
------------------------------------------
1.创建 WinUI 3 和 UWP 空白项目,项目使用的配置: .NET 9 rc 2,CsWinRT 2.1.6,Windows App SDK 1.6.240923002 2.应用初始化完成后,添加如下代码
TypedEventHandler<CoreWindow, object> windowPositionChangedEventHandler = new(OnWindowPositionChanged);
IObjectReference objectReference = MarshalInterface<TypedEventHandler<CoreWindow,object>>.CreateMarshaler(windowPositionChangedEventHandler);
3.在 UWP 中发生了异常,WinUI 3 项目顺利执行。
Expected Behavior
The above types of code will hopefully be called smoothly in UWP as well
------------------------------------------
上述类型代码希望也可以在 UWP 中顺利调用
Version Info
CsWinRT 2.1.6 .NET 9 RC2 Windows App SDK 1.6.240923002 Visual Studio 2022 17.12.preview 4.0
Additional Context
ScreenShot(截图)
------------------------------------------
UWP
------------------------------------------
WinUI 3