Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Passing object by ref to COM not working

$
0
0

Guys,

Newbee just getting into C# needs to help:

I'm trying to call a dll functions which looks like this:

public double[,] Correl(string action, ref object returns, double observation_frequency);

Issue is in second argument, which seems to require  data type like {Int32 UBound(System.Array, Int32)}

My call looks like this:

Double[] vect1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };// {{ 1, 2, 3, 4, 5, 6, 7, 8, 9 },{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }};
object oncloses = vect1;
nFullMatrix = Correl.Correl((string)"AVC",ref oncloses, (double)frequency); 

When for testing I call with onedimensional array I get error: Argument 'Rank' is not valid for the array. Know that it requires two dimensions, but at least values seem to pass and something happens :-)

When I call with twodimensional array like below, I get error: Parametername: Argument 'Array' is Nothing.

Double[,] vect1 = {{ 1, 2, 3, 4, 5, 6, 7, 8, 9 },{ 1, 2, 3, 4, 5, 6, 7, 8, 9 }};

I was using this from VBA/Excel quite a lot without any issue, using type universal Variant, but seems C# is a bit more picky..

Spent my afternoon online looking for the trick, please tell me it's really tricky not to get frustrated..

Thanks in advance,

Alex



Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>