Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to cast object of type 'WinRT.ObjectReferenceValue' to type 'WinRT.IObjectReference' #1162

Closed
manodasanW opened this issue Apr 5, 2022 · 0 comments · Fixed by #1160
Assignees
Labels
bug Something isn't working

Comments

@manodasanW
Copy link
Member

manodasanW commented Apr 5, 2022

When using the .24 version of the Windows SDK projection with a CsWinRT projection built using CsWinRT 1.3.0 or earlier, you may run into Unable to cast object of type 'WinRT.ObjectReferenceValue' to type 'WinRT.IObjectReference' when using events from those projections. This is due to a compat regression in the latest WinRT.Runtime from the generic marshaler updates. This issue doesn't affect CsWinRT projections generated using >= 1.3.1.

Workarounds until a fix is available:

  • If the events being used are from Win2D, update to the latest Win2D update (1.0.1) which has an updated CsWinRT projection which doesn't hit the issue.
  • If it is in your own projection, the recommendation is to move to a newer version of CsWinRT (anything after 1.3.1, preferably latest or 1.5.0) to build your projection.
  • Use the WindowsSdkPackageVersion property to pick up the .25 version of the Windows SDK projection which has the fix for this issue. i.e if you are targeting the 19041 Windows API version in your TFM, you can set the property <WindowsSdkPackageVersion>10.0.19041.25</WindowsSdkPackageVersion> to pick up the .25 version. This is only needed until the next .NET SDK update which should have this version with the fix.

If you are running into this same issue outside of events, that would be a different issue from this, and a new bug should be opened to track and investigate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
1 participant