Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to pass .NET array to COM VB6 library. I have an object which is COM wrapper of VB6 object. It has method with the following signature:

[MethodImpl(MethodImplOptions.InternalCall, 
    MethodCodeType = MethodCodeType.Runtime)]
void AddEx([MarshalAs(UnmanagedType.Struct)] object vSafeArrayOfItems);

but when I call it I get an ArgumentException with the following message:

Value does not fall within the expected range.

The type of exception and its description doesn't even depend on passed element.

Does anybody know how to go around this issue?

UPD: I removed .NET wrapper assemblies and referrenced source .COM libraries. No changes had happened.

share|improve this question
2  
The [MarshalAs] attribute is clearly wrong. – Hans Passant Aug 27 '12 at 11:55
Agreed. @user1453239 why did you think it was a struct? – tcarvin Aug 27 '12 at 12:17
This declaratioin is from library which i'm trying to use. It is provided by third party developer. – user1453239 Aug 27 '12 at 12:22

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.