Click here to Skip to main content
16,010,268 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
Heath Stewart16-Apr-05 22:53
protectorHeath Stewart16-Apr-05 22:53 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
shusong16-Apr-05 23:19
shusong16-Apr-05 23:19 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
Heath Stewart16-Apr-05 23:47
protectorHeath Stewart16-Apr-05 23:47 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
shusong17-Apr-05 1:04
shusong17-Apr-05 1:04 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
shusong17-Apr-05 15:15
shusong17-Apr-05 15:15 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
Heath Stewart17-Apr-05 16:28
protectorHeath Stewart17-Apr-05 16:28 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
shusong17-Apr-05 16:49
shusong17-Apr-05 16:49 
GeneralRe: How to use CStringArray in C# using p/invoke Pin
Heath Stewart18-Apr-05 6:59
protectorHeath Stewart18-Apr-05 6:59 
One problem could be that the marhsaler must know the size of the array, but one must use MarshalAsAttribute.SizeConst and MarshalAsAttribute.SizeParamIndex only works for marshaling method parameters, not struct fields.

The Marshal class in System.Runtime.InteropServices can be useful for custom marshaling, which you can read about here: http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemRuntimeInteropServicesICustomMarshalerClassTopic.asp[^].

Also, the native code is different from your original code you posted. Since you are not instantiating the CStringArray then you must use ref instead of out in your P/Invoke signature and must instantiate the managed CStringArray. You can read about the differences between ref and out here: http://msdn.microsoft.com/library/en-us/csref/html/vclrfPassingMethodParameters.asp[^]. Since CStringArray is a class, it will be a reference type. Try just leaving off the ref or out and declaring the parameter simply as (CStringArray stringArray). Typically out and ref are used with struct params, since structs are value types and are passed by-value; or with double pointers for reference types.

Finally, I am not debugging your code. This development community is here to help you learn, but not to do your work. That will never teach anyone anything. Debugging your code and helping to diagnose the problem is what you should be doing and is part of the development lifecycle.

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Customer Product-lifecycle Experience
Microsoft

[My Articles] [My Blog]
GeneralRe: How to use CStringArray in C# using p/invoke Pin
ttcchh200812-Jun-10 3:14
ttcchh200812-Jun-10 3:14 
Questionhow to implement WHITEBOARD for many users Pin
xinxin_52515-Apr-05 23:33
xinxin_52515-Apr-05 23:33 
AnswerRe: how to implement WHITEBOARD for many users Pin
Colin Angus Mackay15-Apr-05 23:48
Colin Angus Mackay15-Apr-05 23:48 
GeneralURI format not supported Pin
Adnan Siddiqi15-Apr-05 22:29
Adnan Siddiqi15-Apr-05 22:29 
GeneralRe: URI format not supported Pin
Heath Stewart16-Apr-05 8:18
protectorHeath Stewart16-Apr-05 8:18 
GeneralRe: URI format not supported Pin
Adnan Siddiqi17-Apr-05 6:00
Adnan Siddiqi17-Apr-05 6:00 
GeneralRe: URI format not supported Pin
Heath Stewart17-Apr-05 16:24
protectorHeath Stewart17-Apr-05 16:24 
GeneralFun with collections... Pin
tantiboh15-Apr-05 22:13
tantiboh15-Apr-05 22:13 
GeneralRe: Fun with collections... Pin
Colin Angus Mackay15-Apr-05 23:37
Colin Angus Mackay15-Apr-05 23:37 
GeneralRe: Fun with collections... Pin
tantiboh16-Apr-05 6:29
tantiboh16-Apr-05 6:29 
GeneralVS.NET 2003 IDE Pin
pmasknguyen15-Apr-05 18:43
pmasknguyen15-Apr-05 18:43 
GeneralRe: VS.NET 2003 IDE Pin
leppie15-Apr-05 21:05
leppie15-Apr-05 21:05 
GeneralWeb Page Generator using C... Pin
ZMAN072815-Apr-05 14:16
ZMAN072815-Apr-05 14:16 
GeneralRe: Web Page Generator using C... Pin
Yulianto.15-Apr-05 16:07
Yulianto.15-Apr-05 16:07 
Questionget size of picture folder?? Pin
Anonymous15-Apr-05 12:58
Anonymous15-Apr-05 12:58 
AnswerRe: get size of picture folder?? Pin
Nicholas Cardi15-Apr-05 13:21
Nicholas Cardi15-Apr-05 13:21 
GeneralAppDomain Question Pin
cobyjone15-Apr-05 12:53
cobyjone15-Apr-05 12:53 

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.