Unity crash when using Marshal.PtrToStructure

MyCamera.MV_CC_DEVICE_INFO device = (MyCamera.MV_CC_DEVICE_INFO)Marshal.PtrToStructure(m_stDeviceList.pDeviceInfo[i], typeof(MyCamera.MV_CC_DEVICE_INFO)); this code works fine in visualstudio project .net Application ,but I copy this code into unity and run,unity crash !