Hello,
I’d like to store some user defined information on a Camera (Dalsa Nano) with GenApi.NMUploadFileMemory and read it back into my application with GenApi.NMDownloadFileMemory.
Uploading some information provided by a file on my HDD by using GenApi.NMUploadFile works gracefully.
Downloading this information into a byte[] is also no problem.
When I try to upload some data stored in a pinned byte[], my application just exits with Code 3 without any further information.
Do I misunderstand the purpose of NMUploadFileMemory?
Or may there be security issues when CVB tries to read in memory directly?
Here’s some sample Code:
public unsafe void Upload()
{
Driver.INodeMapHandle.NMHGetNodeMap(cameraDriver, out SharedNodeMap nodeMap);
byte[] d = Encoding.ASCII.GetBytes("This is a test");
fixed(byte* array=d)
{
GenApi.NMUploadFileMemory(nodeMap, "userDefinedSavedImage", (IntPtr)array,d.Length);
}
}
public byte[] DownloadData()
{
int l = 1024 * 1024;
IntPtr pt = Marshal.AllocHGlobal(l);
GenApi.NMDownloadFileMemory(deviceNodeMap, "userDefinedSavedImage", pt, ref l);
byte[] data = new byte[l];
Marshal.Copy(pt, data, 0, l);
Marshal.FreeHGlobal(pt);
return data;
}
I’m using VisualStudio 2017, .NET 4.5, and CVB 13.01 (64bit).
Thanks in advance for any hints.
Andi