排错“未能封送类型,因为嵌入数组实例的长度与布局中声明的长度不匹配”

问题:
在C#给C++传数组类型数据时报此错,相应英文信息为“Type could not be marshaled, because the length of an embed array doesn't not match the declared length in the layout”


原因
1、声明的数组长度和实际的数组长度不一致,比如声明的数组长度为1000,实际数组里放了1000多。