microsoft / CsWin32

A source generator to add a user-defined set of Win32 P/Invoke methods and supporting types to a C# project.
MIT License
1.99k stars 84 forks source link

"Pointers cannot reference marshaled structures. Use ByRef instead" caused by VariableLengthInlineArray #1218

Open Nuklon opened 1 week ago

Nuklon commented 1 week ago

Actual behavior

Pointers cannot reference marshaled structures. Use ByRef instead. Only happens on .NET Framework 472. If you remove the public global::Windows.Win32.VariableLengthInlineArray<char> HardwareID; field from SP_DRVINFO_DETAIL_DATA_W it works correctly. It worked correctly in CsWin32 0.3.49.

Expected behavior

Work correctly.

Repro steps

  1. NativeMethods.txt content:

    SetupDiGetDriverInfoDetail
  2. NativeMethods.json content (if present):

  3. Any of your own code that should be shared?

Context