Click here to Skip to main content
15,885,366 members
Home / Discussions / C#
   

C#

 
AnswerRe: help PinPopular
Luc Pattyn16-Dec-11 15:01
sitebuilderLuc Pattyn16-Dec-11 15:01 
GeneralRe: help Pin
BillWoodruff16-Dec-11 18:12
professionalBillWoodruff16-Dec-11 18:12 
AnswerRe: help Pin
Pete O'Hanlon16-Dec-11 23:38
mvePete O'Hanlon16-Dec-11 23:38 
AnswerRe: help Pin
#realJSOP17-Dec-11 3:04
mve#realJSOP17-Dec-11 3:04 
GeneralReason for my vote of 1 Pin
Manfred Rudolf Bihy17-Dec-11 15:21
professionalManfred Rudolf Bihy17-Dec-11 15:21 
GeneralRe: Reason for my vote of 1 PinPopular
#realJSOP18-Dec-11 0:57
mve#realJSOP18-Dec-11 0:57 
AnswerRe: help Pin
AmitGajjar17-Dec-11 7:22
professionalAmitGajjar17-Dec-11 7:22 
Questionunmanaged - returning arrays Pin
Mark H Bishop16-Dec-11 12:26
Mark H Bishop16-Dec-11 12:26 
(VS C# 2008 and C++ 2008)

I have a win32 c++ application with an entry point:

C++
extern "C" int __declspec(dllexport) __stdcall ret_arr(float returnArray[])
{
	float myArray[2];
	myArray[0]=1.2;
	myArray[1] = 2.4;
	returnArray = myArray;
	return 1;
}


I'm trying to get the array "returnArray[]" from C#:

C#
[DllImport("MyDll.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "ret_arr")]
        public static extern int ret_arr([MarshalAs(UnmanagedType.LPArray)] ref float[] retArray);


        private void test()
        {
            float[] retArray = null;
            int ans = ret_arr(ref retArray);

        }




When I call my C# function - test() - in the debugger, "retArray" isn't being assigned (it remains null). Likewise, if I initialize the retArray (= new Float[2]) the array is not modified after it returns from the unmanaged dll.

I don't have any trouble retrieving a float. But working with float[] has me jammed-up. I have tried many variations including passing the argument as a pointer but I cannot, with my skillset, figure it out.

What should I try next?
AnswerRe: unmanaged - returning arrays Pin
Luc Pattyn16-Dec-11 15:08
sitebuilderLuc Pattyn16-Dec-11 15:08 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 4:08
Mark H Bishop17-Dec-11 4:08 
GeneralRe: unmanaged - returning arrays Pin
Luc Pattyn17-Dec-11 4:22
sitebuilderLuc Pattyn17-Dec-11 4:22 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 7:22
Mark H Bishop17-Dec-11 7:22 
AnswerRe: unmanaged - returning arrays Pin
Luc Pattyn17-Dec-11 7:40
sitebuilderLuc Pattyn17-Dec-11 7:40 
GeneralRe: unmanaged - returning arrays Pin
harold aptroot17-Dec-11 5:13
harold aptroot17-Dec-11 5:13 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 7:16
Mark H Bishop17-Dec-11 7:16 
GeneralRe: unmanaged - returning arrays Pin
Mark H Bishop17-Dec-11 7:29
Mark H Bishop17-Dec-11 7:29 
QuestionCoolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 11:23
SledgeHammer0116-Dec-11 11:23 
AnswerRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 11:34
mvePIEBALDconsult16-Dec-11 11:34 
GeneralRe: Coolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 11:44
SledgeHammer0116-Dec-11 11:44 
GeneralRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 11:52
mvePIEBALDconsult16-Dec-11 11:52 
GeneralRe: Coolest way to do this string operation? Pin
SledgeHammer0116-Dec-11 12:06
SledgeHammer0116-Dec-11 12:06 
GeneralRe: Coolest way to do this string operation? Pin
Not Active16-Dec-11 13:54
mentorNot Active16-Dec-11 13:54 
AnswerRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 11:50
protectorAspDotNetDev16-Dec-11 11:50 
GeneralRe: Coolest way to do this string operation? Pin
PIEBALDconsult16-Dec-11 11:57
mvePIEBALDconsult16-Dec-11 11:57 
AnswerRe: Coolest way to do this string operation? Pin
AspDotNetDev16-Dec-11 12:05
protectorAspDotNetDev16-Dec-11 12:05 

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.