amerkoleci / Vortice.Win32

Low level .NET bindings for Win32 Api.
MIT License
49 stars 2 forks source link

System.InvalidCastException for NET8 #3

Closed RoccoZero closed 1 year ago

RoccoZero commented 1 year ago

07:35:41 | ERROR | System.InvalidCastException: Unable to cast object of type 'Win32.Graphics.Direct2D.AffineTransform2DProperties' to type 'System.UInt32'. at Win32.Graphics.Direct2D.ID2D1PropertiesExtensions.SetValue[TD2D1Properties,T,U](TD2D1Properties& self, U index, T* value) in D:\a\Vortice.Win32\Vortice.Win32\src\Vortice.Win32.Graphics.Direct2D\ID2D1Properties.cs:line 59

image
amerkoleci commented 1 year ago

Version 2.1.0 fixes this issue. Thanks for reporting

RoccoZero commented 1 year ago

I keep getting this error on Version 2.1.0

23:33:12 | ERROR | System.InvalidCastException: Unable to cast object of type 'Win32.Graphics.Direct2D.AffineTransform2DProperties' to type 'System.UInt32'.
   at Win32.Graphics.Direct2D.ID2D1PropertiesExtensions.SetValue[TD2D1Properties,T,U](TD2D1Properties& self, U index, T* value) in D:\a\Vortice.Win32\Vortice.Win32\src\Vortice.Win32.Graphics.Direct2D\ID2D1Properties.cs:line 257
amerkoleci commented 1 year ago

Call SetEnumValue

RoccoZero commented 1 year ago

i can't use SetEnumValue I need SetValue because that's where I send the matrix I get an error if I use SetValue and the first parameter index is Enum

image
amerkoleci commented 1 year ago

Then use SetValue and pass the Matrix3x2, without the &translation, just use translation

RoccoZero commented 1 year ago

this working SetValue((uint)AffineTransform2DProperties.TransformMatrix, translation);

but why can’t I remove enum cast to uint? It worked before (uint)AffineTransform2DProperties.TransformMatrix

RoccoZero commented 1 year ago

C++ looks like this, no need to cast

image
amerkoleci commented 1 year ago

C# enums are different from C++ one

RoccoZero commented 1 year ago

I think that you have some kind of problem here, I don’t see any difference here this SetEnumValue is not needed

image
amerkoleci commented 1 year ago

Send PR, thanks!

RoccoZero commented 1 year ago

I found another mistake, you don't use ": uint" image

because of this, this code of yours is useless for the enum type it gives this error System.InvalidCastException: Unable to cast object of type 'Win32.Graphics.Direct2D.AffineTransform2DProperties' to type 'System.UInt32'. image

this is how it was on the old version image