In haikang, there is a video function, in which a callback function needs to be registered and then read the content.
I found that after each call, there was no problem for the first time, but after the second call, "try to read or write the protected memory. This usually indicates that other memory is damaged ."
The document mentions:
Http://topic.csdn.net/u/20080327/14/fb1b0644-2557-4f0d-a39d-16264b22b490.html
NET is the automatic management of memory, the memory will be automatically recycled
Hikvision's API is implemented by C ++, and C ++ manages the memory by the user.
When executed in the callback function ,. the memory has been recycled in. NET, but you still need to read the memory, and "try to read or write the protected memory" will appear. This usually indicates other memory corruption "error
Again, google the secret:
Also, make sure the lifetime of the delegate instance covers the lifetime of the unmanaged code; otherwise, the delegate will not be available after it is garbage-collected.
The problem should be that my callback function is put in the class and recycled by the memory .. This is probably the problem. After reading the public code on the internet, others' delegate are all outside the class.