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

C#

 
AnswerRe: Is there anything built in for distributed applications? Pin
Mycroft Holmes15-Mar-11 12:32
professionalMycroft Holmes15-Mar-11 12:32 
GeneralRe: Is there anything built in for distributed applications? Pin
SledgeHammer0115-Mar-11 12:44
SledgeHammer0115-Mar-11 12:44 
GeneralRe: Is there anything built in for distributed applications? Pin
Mycroft Holmes15-Mar-11 14:09
professionalMycroft Holmes15-Mar-11 14:09 
GeneralRe: Is there anything built in for distributed applications? Pin
SledgeHammer0115-Mar-11 14:24
SledgeHammer0115-Mar-11 14:24 
AnswerIt's Similar with my case. Pin
SungBae.Han15-Mar-11 13:16
SungBae.Han15-Mar-11 13:16 
AnswerRe: Is there anything built in for distributed applications? Pin
Albert Holguin15-Mar-11 13:31
professionalAlbert Holguin15-Mar-11 13:31 
AnswerRe: Is there anything built in for distributed applications? Pin
GlobX15-Mar-11 20:01
GlobX15-Mar-11 20:01 
Question_msize() on managed data arrays? Pin
Chesnokov Yuriy15-Mar-11 8:38
professionalChesnokov Yuriy15-Mar-11 8:38 
There is a native function wich takes arrays of pointers to data arrays e.g. char allocated with malloc.

void function(char** data, int nRows)
{
 for (int i = 0; i < nRows; i++)
 {
   int nCols = _msize(data[i]);
   for (j = 0; j < nCols; j++)
    char val = data[i][j];
 }
}


In managed code I have enumeration of byte[] arrays to pass to that function via PInvoke

unsafe void MyFunction(IEnumerable<byte[]> data)
{
 var handles = data.Select(d => GCHandle.Alloc(d, GCHandleType.Pinned));
 var ptrs = handles.Select(h => h.AddrOfPinnedObject());
 IntPtr[] dataPtrs = ptrs.ToArray();
 uint nRows = (uint)dataPtrs.Length;
 
 function(dataPtrs, nRows); 
 
 handles.ToList().ForEach(h => h.Free());
}

[DllImport("function.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
static extern unsafe internal void function(IntPtr[] data, uint nRows);


However _msize call in native code leads to heap corruption. I remeber I used stackalloc with one dimensional array char* and concatenated byte[] arrays together.
But I need support for 'jagged array' with individual byte[] arrays of different sizes hence the need for array of pointers char**.

How to pin the byte[] arrays so that _msize correctly works as in stackalloc case?
Чесноков

AnswerRe: _msize() on managed data arrays? Pin
_Erik_16-Mar-11 4:13
_Erik_16-Mar-11 4:13 
QuestionImage Quality Improve Pin
Orcun Iyigun15-Mar-11 8:21
Orcun Iyigun15-Mar-11 8:21 
AnswerRe: Image Quality Improve Pin
Luc Pattyn15-Mar-11 8:42
sitebuilderLuc Pattyn15-Mar-11 8:42 
GeneralRe: Image Quality Improve Pin
Orcun Iyigun15-Mar-11 9:14
Orcun Iyigun15-Mar-11 9:14 
QuestionCrystal Reports Problem Pin
Kevin Marois15-Mar-11 8:00
professionalKevin Marois15-Mar-11 8:00 
AnswerRe: Crystal Reports Problem Pin
Q_rioso28-Apr-11 1:34
Q_rioso28-Apr-11 1:34 
Questionrun program from many PCs and database in one machine ? Pin
Nabawoka15-Mar-11 6:53
Nabawoka15-Mar-11 6:53 
AnswerRe: run program from many PCs and database in one machine ? Pin
Praveen Raghuvanshi15-Mar-11 7:02
professionalPraveen Raghuvanshi15-Mar-11 7:02 
GeneralRe: run program from many PCs and database in one machine ? Pin
Nabawoka15-Mar-11 7:05
Nabawoka15-Mar-11 7:05 
AnswerRe: run program from many PCs and database in one machine ? Pin
Dan Mos15-Mar-11 7:50
Dan Mos15-Mar-11 7:50 
GeneralRe: run program from many PCs and database in one machine ? Pin
Nabawoka15-Mar-11 8:16
Nabawoka15-Mar-11 8:16 
GeneralRe: run program from many PCs and database in one machine ? Pin
Dan Mos15-Mar-11 8:25
Dan Mos15-Mar-11 8:25 
QuestionCoverting MP3's to MP3 Pro VBR Pin
Chrispie12315-Mar-11 4:59
Chrispie12315-Mar-11 4:59 
QuestionEncryption with advapi32.dll Pin
garfield18515-Mar-11 3:38
garfield18515-Mar-11 3:38 
AnswerRe: Encryption with advapi32.dll Pin
Richard MacCutchan15-Mar-11 3:47
mveRichard MacCutchan15-Mar-11 3:47 
GeneralRe: Encryption with advapi32.dll Pin
garfield18515-Mar-11 4:45
garfield18515-Mar-11 4:45 
GeneralRe: Encryption with advapi32.dll Pin
Richard MacCutchan15-Mar-11 4:56
mveRichard MacCutchan15-Mar-11 4:56 

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.