By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,601 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,601 IT Pros & Developers. It's quick & easy.

passing C# array by ref to Delphi Com dll

P: 2
Hi,

I have to pass an array by ref to a referenced Delphi Com dll, but all my attempts end in an error.
I'm using VS2003 and I referenced the com dll in my project with 'add reference'.
The Delphi dll has e.g. a procedure Test with a parameter aParam:
Expand|Select|Wrap|Line Numbers
  1.  procedure Test(var aParam: OleVariant) 
After referencing in C# this procedure is:
Expand|Select|Wrap|Line Numbers
  1.  void Test(ref object aParam) 
The aParam parameter is a 1-dimensional array with floats.
I tested with this code:
Expand|Select|Wrap|Line Numbers
  1. object testparam = new float[] {1, 2, 3};
  2. Test(ref testparam);
but the Delphi dll returns an exception with the message 'Variant is not an array'.

What can I do?

Thanks!
Apr 26 '07 #1
Share this Question
Share on Google+
2 Replies


radcaesar
Expert 100+
P: 759
Try This,

System.Array=new new float[] {1, 2, 3};
Test(ref testparam);


Hi,

I have to pass an array by ref to a referenced Delphi Com dll, but all my attempts end in an error.
I'm using VS2003 and I referenced the com dll in my project with 'add reference'.
The Delphi dll has e.g. a procedure Test with a parameter aParam:
Expand|Select|Wrap|Line Numbers
  1.  procedure Test(var aParam: OleVariant) 
After referencing in C# this procedure is:
Expand|Select|Wrap|Line Numbers
  1.  void Test(ref object aParam) 
The aParam parameter is a 1-dimensional array with floats.
I tested with this code:
Expand|Select|Wrap|Line Numbers
  1. object testparam = new float[] {1, 2, 3};
  2. Test(ref testparam);
but the Delphi dll returns an exception with the message 'Variant is not an array'.

What can I do?

Thanks!
Apr 26 '07 #2

P: 2
this is not building, testparam has to be type object
Apr 27 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.