Click here to Skip to main content
15,888,113 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy18-Jan-11 8:07
professionalChesnokov Yuriy18-Jan-11 8:07 
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 
There is exception in calling byte[][] signature
"Cannot marshal 'parameter #1': There is no marshaling support for nested arrays." System.Exception System.Runtime.InteropServices.MarshalDirectiveException<br />


unsafe static void Print()
{
        Random random = new Random();
                        
        List<int[]> list = new List<int[]>();
        int nRows = random.Next(1, 25);
        for (int i = 0; i < nRows; i++)
        {
                int nCols = random.Next(1, 25);
                int[] row = new int[nCols];
                row[0] = nCols;
                list.Add(row);
        }

        int[][] data = new int[list.Count][];
        for (int i = 0; i < list.Count; i++)
                data[i] = list[i];
                        
        print(data, nRows);
}

[DllImport("native.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
static extern unsafe int print(int[][] data, int nRows);

NATIVE_API void print(int** data, int nRows)
{
        _tprintf(_T("data** size: %d\n"), sizeof(data));
        _tprintf(_T(" data* size: %d\n"), sizeof(data[0]));
	for (int i = 0; i < nRows; i++) {
                int nCols = data[i][0]; 
                for (int j = 0; j < nCols; j++)
                        _tprintf(_T("%3d "), data[i][j]);
                _tprintf(_T("\n"));
        }
}


Are you sure you tried that approach without exceptions?
Also if using byte[,] instead of jagged byte[][] the pointer passed to unmanaged functions turned out to be of 0x00000000 value when I stepped in.

}8-0 I'm going to change my votes ....
Чесноков

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 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_19-Jan-11 3:06
_Erik_19-Jan-11 3:06 
GeneralRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 4:18
professionalChesnokov Yuriy19-Jan-11 4:18 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_19-Jan-11 5:10
_Erik_19-Jan-11 5:10 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 9:45
professionalChesnokov Yuriy19-Jan-11 9:45 
GeneralRe: How to pin List to unmanaged byte** [modified] Pin
_Erik_19-Jan-11 10:55
_Erik_19-Jan-11 10:55 
AnswerRe: How to pin List to unmanaged byte** Pin
Chesnokov Yuriy19-Jan-11 19:12
professionalChesnokov Yuriy19-Jan-11 19:12 
GeneralRe: How to pin List to unmanaged byte** Pin
_Erik_20-Jan-11 2:37
_Erik_20-Jan-11 2:37 

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.