回答編集履歴

2

LayoutKind忘れ

2021/09/09 23:02

投稿

退会済みユーザー
test CHANGED
@@ -32,6 +32,8 @@
32
32
 
33
33
  {
34
34
 
35
+ [StructLayout(LayoutKind.Sequential)]
36
+
35
37
  struct A
36
38
 
37
39
  {
@@ -43,6 +45,8 @@
43
45
  }
44
46
 
45
47
 
48
+
49
+ [StructLayout(LayoutKind.Sequential)]
46
50
 
47
51
  struct DynamicArray
48
52
 

1

追記

2021/09/09 23:02

投稿

退会済みユーザー
test CHANGED
@@ -3,6 +3,12 @@
3
3
  [アンマネージ コードとの相互運用](https://docs.microsoft.com/ja-jp/dotnet/framework/interop/)
4
4
 
5
5
  [ネイティブ相互運用性](https://docs.microsoft.com/ja-jp/dotnet/standard/native-interop/)
6
+
7
+ [ネイティブ相互運用性のベスト プラクティス](https://docs.microsoft.com/ja-jp/dotnet/standard/native-interop/best-practices)
8
+
9
+
10
+
11
+ 今回の例だと、このへんでしょう。
6
12
 
7
13
  [クラス、構造体、および共用体のマーシャリング](https://docs.microsoft.com/ja-jp/dotnet/framework/interop/marshaling-classes-structures-and-unions)
8
14