fergs
fergs

Reputation: 183

c# wrapper and issue with protected memory

So I've now progressed to having an almost functioning wrapper.
Other posts regarding my wrapper issues are:
C# wrapper and Callbacks &
C# wrapper for array of three pointers

I use the wrapper to establish a connection to the Dallmeier using the following:

_dallmeier.SessionHandle = DallmeierSDK.dlm_connect(_handle, _ip, "", _pass, null, null, connectionCallback, pInPut)  

This returns the session handler. After awhile I get a AccessVoilationException about attempted to read or write protected memory.

I think this has something to do with using Marshal.Read and/or Marshal.Copy (as stated in one of the posts above) but I'm not sure where I use these commands.

Can some please advise me on this and/or examples?

Upvotes: 0

Views: 180

Answers (1)

ralf.w.
ralf.w.

Reputation: 1696

maybe you could try wrapping your code in a fixed block, to prevent moving the pointer in memory or being GC-collected.

Upvotes: 1

Related Questions