Click here to Skip to main content
15,910,009 members
Home / Discussions / C#
   

C#

 
GeneralRe: project options (advice) Pin
HudsonKane24-Aug-04 8:19
HudsonKane24-Aug-04 8:19 
GeneralWeb application config Pin
jzb24-Aug-04 3:09
jzb24-Aug-04 3:09 
GeneralRe: Web application config Pin
Steven Campbell24-Aug-04 3:51
Steven Campbell24-Aug-04 3:51 
QuestionHow can I pass byte array from C++ to c# ? Pin
neoksd24-Aug-04 2:31
neoksd24-Aug-04 2:31 
AnswerRe: How can I pass byte array from C++ to c# ? Pin
billb211224-Aug-04 3:31
billb211224-Aug-04 3:31 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
neoksd24-Aug-04 4:16
neoksd24-Aug-04 4:16 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
billb211224-Aug-04 5:45
billb211224-Aug-04 5:45 
AnswerRe: How can I pass byte array from C++ to c# ? Pin
Heath Stewart24-Aug-04 8:03
protectorHeath Stewart24-Aug-04 8:03 
An unmanaged long is 32 bits, not 64; therefore, an int (System.Int32) is the correct type to marshal to your COM object.

Also, your SizeParamIndex isn't valid. Your array is passed in parameter 0, not your size. You actually shouldn't even need to use the MarshalAsAttribute here. A byte[] array is already a reference type (a managed pointer, if you will), and passing that with out yields a pointer to your pointer, just like a BYTE** (or LPBYTE*). Without declaring SizeParamIndex or SizeConst, however, you'll run into a problem.

When marshalling from unmanaged to managed code (or even just passing data in unmanaged code with or without marshalling), there's no way to infer the size of an array (of whatever data type). If this is an interface you declared, you really should define another parameter that returns the number of bytes in the array - not just for the sake of .NET - but for any callers (unless the size is always known, in which case you should use the SizeConst field in your MarshalAsAttibute).

 

Software Design Engineer
Developer Division Sustained Engineering, Microsoft
My Articles
GeneralRe: How can I pass byte array from C++ to c# ? Pin
neoksd26-Aug-04 15:23
neoksd26-Aug-04 15:23 
GeneralRe: Declaration Default Argument Values Pin
S Sansanwal23-Aug-04 23:54
S Sansanwal23-Aug-04 23:54 
GeneralRe: Declaration Default Argument Values Pin
Heath Stewart24-Aug-04 8:09
protectorHeath Stewart24-Aug-04 8:09 
GeneralHosting Managed Controls in MFC Pin
Amir Harel23-Aug-04 23:13
Amir Harel23-Aug-04 23:13 
Generaldatabound list with customisable filter Pin
..Hubert..23-Aug-04 23:03
..Hubert..23-Aug-04 23:03 
GeneralIP-Tunnel Pin
erina54823-Aug-04 22:55
erina54823-Aug-04 22:55 
GeneralRe: IP-Tunnel Pin
Dave Kreskowiak24-Aug-04 6:56
mveDave Kreskowiak24-Aug-04 6:56 
GeneralISOBARS Pin
beolijza23-Aug-04 22:39
beolijza23-Aug-04 22:39 
QuestionHow do I call a base class function from a derived class function? Pin
Salil Khedkar23-Aug-04 20:21
Salil Khedkar23-Aug-04 20:21 
AnswerRe: How do I call a base class function from a derived class function? Pin
Colin Angus Mackay23-Aug-04 20:44
Colin Angus Mackay23-Aug-04 20:44 
GeneralRe: How do I call a base class function from a derived class function? Pin
Salil Khedkar23-Aug-04 21:19
Salil Khedkar23-Aug-04 21:19 
GeneralRe: How do I call a base class function from a derived class function? Pin
leppie23-Aug-04 21:31
leppie23-Aug-04 21:31 
GeneralRe: How do I call a base class function from a derived class function? Pin
Colin Angus Mackay24-Aug-04 0:29
Colin Angus Mackay24-Aug-04 0:29 
AnswerRe: How do I call a base class function from a derived class function? Pin
Salil Khedkar23-Aug-04 22:11
Salil Khedkar23-Aug-04 22:11 
GeneralNew to C# Pin
Vicks23-Aug-04 20:00
Vicks23-Aug-04 20:00 
GeneralRe: New to C# Pin
Colin Angus Mackay23-Aug-04 20:29
Colin Angus Mackay23-Aug-04 20:29 
GeneralRe: New to C# Pin
Salil Khedkar23-Aug-04 20:30
Salil Khedkar23-Aug-04 20:30 

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.