You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In porting a library to WinUI3, a class started throwing an InvalidCastException.
It appears to fail trying to QI the class to an IDependencyObject.
This QI succeeds when done from a UAP but fails in a Desktop packaged app.
Version Info
CsWinRT 1.1.4
.NET SDK 10.0.19041.15
ProjectReunion.0.5.0-prerelease
The text was updated successfully, but these errors were encountered:
@getrou - Are you authoring a C#/WinRT component? I assume you are creating a C#/.NET5 class library, and consuming it in a C# desktop packaged app (Project Reunion)?
I too am encountering invalid cast exception when porting to WinUI3 for a desktop application.
The following line causes the exception to be thrown:
var bitmap = new CanvasRenderTarget(canvasdevice, 16, 16, 96);
Stack trace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at WinRT.IObjectReference.As[T](Guid iid)
at WinRT.IObjectReference.As(Guid iid)
at Microsoft.UI.Xaml.DependencyObject..ctor(IObjectReference objRef)
at Microsoft.Graphics.Canvas.CanvasBitmap..ctor(IObjectReference objRef)
at Microsoft.Graphics.Canvas.CanvasRenderTarget..ctor(IObjectReference objRef)
at Microsoft.Graphics.Canvas.CanvasRenderTarget..ctor(ICanvasResourceCreator resourceCreator, Single width, Single height, Single dpi)
In porting a library to WinUI3, a class started throwing an InvalidCastException.
It appears to fail trying to QI the class to an IDependencyObject.
This QI succeeds when done from a UAP but fails in a Desktop packaged app.
Version Info
CsWinRT 1.1.4
.NET SDK 10.0.19041.15
ProjectReunion.0.5.0-prerelease
The text was updated successfully, but these errors were encountered: