We are using visual studio 2008-My requirement is to allocate some memory, store data into that allocated memory and pass the memory address to a DLL written in C. But when try to pass this memory address to a function in that DLL my application crashes and shows the message "The memory could not be written".
''//Memory allocation Code
Dim tmpPtr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Array.GetValue(Array.GetLowerBound(0), Array.GetLowerBound(1))))
''//Copying data to memory
Marshal.StructureToPtr(Array.GetValue(Array.GetLowerBound(0), Array.GetLowerBound(1)), tmpPtr, True)
''//Trying to pass to 'c' dll
StoreStack(tmpPtr)
I'm getting the error at the last line. Can anyone help?