Hey please throw class Marshal because Net 6.x and newer versions of Net publications as NativeAot that's why Marshal doesn't work. Please find alternate to Marshal.Copy() like NativeMemory or fixed block for for or foreach statements etc....
Thanks!