Click here to Skip to main content
15,883,336 members
Home / Discussions / C#
   

C#

 
AnswerRe: Urgent help pleaseeeeeeee..... Pin
papa198016-May-06 22:15
papa198016-May-06 22:15 
AnswerRe: Urgent help pleaseeeeeeee..... Pin
stancrm18-May-06 3:47
stancrm18-May-06 3:47 
Questionsoftware information Pin
Ch_yasir_meh16-May-06 20:59
Ch_yasir_meh16-May-06 20:59 
Questionc#+flash=???? Pin
papa198016-May-06 20:43
papa198016-May-06 20:43 
AnswerRe: c#+flash=???? Pin
Jakob Farian Krarup17-May-06 1:33
Jakob Farian Krarup17-May-06 1:33 
GeneralRe: c#+flash=???? Pin
papa198017-May-06 3:07
papa198017-May-06 3:07 
QuestionConversion of C# code to javascript or VBScript Pin
Avanika Gupta16-May-06 20:32
Avanika Gupta16-May-06 20:32 
QuestionMarshaling structures containing an array of structures Pin
pythoulon16-May-06 19:18
pythoulon16-May-06 19:18 
Hi. I'm trying to use p/invoke on some standard C library. The library defines a struct:
<br />
typedef struct {<br />
	FLAC__FrameHeader header;<br />
	FLAC__Subframe subframes[8];<br />
	FLAC__FrameFooter footer;<br />
} FLAC__Frame;<br />


where FLAC__FrameHeader, FLAC__Subframe, and FLAC__FrameFooter are other copmlex structures.

The library declares a function that consumes a FLAC__Frame as argument, such as :
void someFunc(FLAC__Frame frame);

[These are snippets from libFlac, for those in the know, but this is not really relevant; see here for more on FLAC.]


The question is: how do you marshall the struct to pass it back and forth between C# code and the C library function ?

I've tried to describe the FLAC_Frame structure as this, among other things:
<br />
    [StructLayout(LayoutKind.Sequential)]<br />
    internal struct Frame {<br />
        public FrameHeader Header;<br />
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]<br />
        public Subframe[] Subframes;<br />
        public FrameFooter Footer;<br />
    }<br />
<br />
    [DllImport("libFlac.dll")]<br />
    private static extern void someFunc(Frame frame);<br />


but I keep getting a TypeLoadException with the comment "Cannot marshal field 'Subframes' of type 'Frame': There is no marshaling support for this type."
It does not seem to like the array of Subframes embedded in the Frame structure.

Anybody would have hints ?

Thanks,


Pyt.
AnswerRe: Marshaling structures containing an array of structures Pin
leppie16-May-06 21:17
leppie16-May-06 21:17 
GeneralRe: Marshaling structures containing an array of structures Pin
pythoulon17-May-06 0:04
pythoulon17-May-06 0:04 
GeneralRe: Marshaling structures containing an array of structures Pin
leppie17-May-06 0:28
leppie17-May-06 0:28 
GeneralRe: Marshaling structures containing an array of structures Pin
pythoulon17-May-06 18:20
pythoulon17-May-06 18:20 
QuestionNeed help in type casting Pin
Ashraj198216-May-06 18:11
Ashraj198216-May-06 18:11 
AnswerRe: Need help in type casting Pin
Josh Smith16-May-06 18:31
Josh Smith16-May-06 18:31 
AnswerRe: Need help in type casting Pin
Saqib Mehmood16-May-06 18:45
Saqib Mehmood16-May-06 18:45 
QuestionTransactions for non data related operations Pin
Hari 200916-May-06 14:17
Hari 200916-May-06 14:17 
AnswerRe: Transactions for non data related operations Pin
Not Active16-May-06 15:21
mentorNot Active16-May-06 15:21 
QuestionNewline in DataGrid Pin
Sean8916-May-06 14:06
Sean8916-May-06 14:06 
AnswerRe: Newline in DataGrid Pin
Nader Elshehabi16-May-06 15:42
Nader Elshehabi16-May-06 15:42 
GeneralRe: Newline in DataGrid Pin
Sean8916-May-06 15:47
Sean8916-May-06 15:47 
GeneralRe: Newline in DataGrid Pin
Josh Smith16-May-06 18:40
Josh Smith16-May-06 18:40 
GeneralRe: Newline in DataGrid Pin
leppie16-May-06 19:18
leppie16-May-06 19:18 
QuestionPrinting any file using Shell Pin
emran83416-May-06 13:44
emran83416-May-06 13:44 
AnswerRe: Printing any file using Shell Pin
Nader Elshehabi16-May-06 15:36
Nader Elshehabi16-May-06 15:36 
GeneralRe: Printing any file using Shell Pin
emran83416-May-06 19:06
emran83416-May-06 19:06 

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.