Код: Выделить всё
using System;
using System.Runtime.CompilerServices;
var t = new Test();
var size = Caller.GetSize(t);
Console.WriteLine(size);
public class Caller
{
[UnsafeAccessor(UnsafeAccessorKind.Field, Name = "_size")]
public static extern int GetSize(Test c);
}
public class Test
{
private int _size = 4;
}
Код: Выделить всё
Exe
net8.0
Код: Выделить всё
Fatal error. Internal CLR error. (0x80131506)
at Caller.GetSize(Test)
at Program.$(System.String[])
Есть идеи?
Я ожидал вывода на консоль: 4
Подробнее здесь: https://stackoverflow.com/questions/772 ... -clr-error
Мобильная версия