0

I'm looking for help passing an object with multiple datatypes to a COM object as defined below...

This is the COM object interface:

[id(0x00000004), helpstring("finds the next best item")]
unsigned long GetNextItem([in, out] SAFEARRAY(VARIANT) Content);

This is the array that needs to be passed to the COM object.

content[0][0] = 0.0 
content[0][1] = 1   
content[0][2] = 1   
content[0][3] = 1      
content[0][4] = -1  
content[0][5] = 0.0 
content[0][6] = 0.0

I have 2 issues:

  1. Creating an object in C# 4.0 that can contain multiple data types.
  2. Passing that object to the COM object through it's public interface.

This is the error I cannot get past:

SafeArrayTypeMismatchException{"Specified array was not of the expected type."}

Any help is appreciated!

0

1 Answer 1

2
content[0][0] = 0.0 

That's a jagged array, it cannot be converted to a SafeArray. You'll need to create a multi-dimensional array instead:

var content = new object[42, 666];
content[0, 0] = 0.0;
Sign up to request clarification or add additional context in comments.

1 Comment

That works for the first element, but the next 4 need to be of type integer and the last 2 of double. What object in C# supports multiple datatypes and can be converted/passed to a safearray?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.