Click here to Skip to main content
15,880,392 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to pin List to unmanaged byte** Pin
DaveyM6918-Jan-11 2:57
professionalDaveyM6918-Jan-11 2:57 
QuestionRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 3:03
professionalChesnokov Yuriy18-Jan-11 3:03 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_18-Jan-11 3:01
_Erik_18-Jan-11 3:01 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 3:06
professionalChesnokov Yuriy18-Jan-11 3:06 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_18-Jan-11 3:17
_Erik_18-Jan-11 3:17 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 3:20
professionalChesnokov Yuriy18-Jan-11 3:20 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_18-Jan-11 3:47
_Erik_18-Jan-11 3:47 
GeneralRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 8:07
professionalChesnokov Yuriy18-Jan-11 8:07 
_Erik_ wrote:
Yes, that's right, but when you make a P/Invoke call, the CLR automatically pins the references passed to the unmanaged function into the managed heap, so the references will not move until the call is finished so, if you use references (such as byte[]), there is no need to manually pin them.


_Erik_ wrote:
Try importing the unmanaged function as I told you before, I mean, use byte[][] and not byte** as the type for the first parameter. Belive me, this is the easiest way, it's worth to try. We can try the tricky version later if this does not work.


That is very intresting.
So far declaring DllImport for PInvoke stated to use native pointers and data types and use fixed every time. That actually compiled. It is a great relief to use managed types in PInvoke declarations instead of unmanaged with fixed statements.

However ToArray() produces the copy of the list. I do not want to spawn copies of the data.
Also is there guarantee that byte[][] array layout in managed memory is plain and there will be no access violation?

I need the ability to quickly pass byte[] objects to byte** array of pointers.
Those byte[] arrays can be stored in a List items or each byte[] array can be a Field in another object thus it is not possible to have ToArray on the list of those objects with those byte[] array items.
Чесноков

GeneralRe: How to pin List to unmanaged byte** Pin
DaveyM6918-Jan-11 16:50
professionalDaveyM6918-Jan-11 16:50 
GeneralRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 19:16
professionalChesnokov Yuriy18-Jan-11 19:16 
GeneralRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 1:01
professionalDaveyM6919-Jan-11 1:01 
QuestionRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 1:25
professionalChesnokov Yuriy19-Jan-11 1:25 
AnswerRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 2:40
professionalDaveyM6919-Jan-11 2:40 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 3:00
professionalChesnokov Yuriy19-Jan-11 3:00 
QuestionRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 4:13
professionalChesnokov Yuriy19-Jan-11 4:13 
AnswerRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 5:43
professionalDaveyM6919-Jan-11 5:43 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 9:28
professionalChesnokov Yuriy19-Jan-11 9:28 
GeneralRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 9:31
professionalDaveyM6919-Jan-11 9:31 
AnswerRe: How to pin List to unmanaged byte** [modified] Pin
DaveyM6919-Jan-11 8:48
professionalDaveyM6919-Jan-11 8:48 
AnswerRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 9:23
professionalDaveyM6919-Jan-11 9:23 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 9:35
professionalChesnokov Yuriy19-Jan-11 9:35 
GeneralRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 9:41
professionalDaveyM6919-Jan-11 9:41 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 10:04
professionalChesnokov Yuriy19-Jan-11 10:04 
GeneralRe: How to pin List to unmanaged byte** Pin
DaveyM6919-Jan-11 10:14
professionalDaveyM6919-Jan-11 10:14 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 19:02
professionalChesnokov Yuriy19-Jan-11 19:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.