Previously, the delegate is converted into an internal variable of a method. The result is recorded as follows:
For "WindowsApplication1! Pixysoft. HikVision. STREAM_DIRECT_READ_CALLBACK: Invoke "type of garbage collection delegate for callback. This may cause application crash, damage, and data loss. When delivering delegates to unmanaged code, managed applications must keep these delegates active until you are sure they will not be called again.
After being recorded as an external domain video for more than 10 seconds, the system prompts: Try to read or write the protected memory. This usually indicates that other memory is damaged.
It is estimated that the memory is released...
The following is a summary of delegate. References:
Http://msdn.microsoft.com/zh-cn/library/43yky316 (VS.80). aspx
Http://topic.csdn.net/u/20080423/03/43b58852-5cac-4aac-a7da-6a69e69b21cd.html
Reference:
Http://msdn.microsoft.com/zh-cn/library/system.gc.keepalive.aspx
Http://www.tech-archive.net/Archive/DotNet/microsoft.public.dotnet.languages.csharp/2006-09/msg01380.html
Http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/d12c13a6-f103-48c8-9933-291a1685941a/
Http://blog.csdn.net/fanweiwei/archive/2007/09/11/1780742.aspx
Http://social.msdn.microsoft.com/Forums/en-US/clr/thread/66ea26a6-7c3d-4e96-9336-e3f148659f22/
Http://topic.csdn.net/u/20080423/03/43b58852-5cac-4aac-a7da-6a69e69b21cd.html
Keyword: GC, CALLBACK, DELEGATE, DLLIMPORT
The problem is solved. Is an interface declaration problem:
Incorrect statement:
Public delegate int StreamDirectReadCallback (int channelNumber, [financialas (UnmanagedType. LPArray, SizeConst = 704*576*5)] byte [] DataBuf, uint Length, Pixysoft. hikVision. DS40xxSDK. frameType_t FrameType, System. intPtr context );
Correct statement:
Public delegate int StreamDirectReadCallback (int channelNumber, IntPtr DataBuf, uint Length, Pixysoft. HikVision. DS40xxSDK. FrameType_t FrameType, System. IntPtr context );