Click here to Skip to main content
15,884,537 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The scenario
Our NET service communicates with a COM component.
When we refer it automatically creates an Interop assembly to manage the transition NET> COM and vice versa.
We call methods in COM (outgoing call), and COM calls methods with us (incoming event to our service).
Most of it works as it should, but there is a big problem that we want to get loose.

Problem
Certain calls from COM component to our service are arrays of C-type. Interop assembliet is unable to convey these arrays to us in NET code is not this an array, but only one element. This is also according to the default behavior as seen in the Microsoft documentation.
This is the NET code for a callback from the COM out:

VB
public void GetGroupsConfirmation (
           uint groupAttributesListSize, // parameter that specifies the array size 
           ref tcsGroupAttributes3_t groupAttributes3List, // The first element in the array 
           tcsBoolean_t endOfCollection, // Flag indicating whether this is the last call slope (explained below) 
           short cookie // corresponds to the request we send to determine groups 
) 

The above callback is initiated when we call the COM component to request the return with a list of group attributes.
In this call, we specify, among other things,
a) the cookie value means that we know which of our request that the call slope concerns,
b) how many elements we Maximum want it back in a single callback (there are more group attributes we request more callbacks until endOfCollection is set to True).

What we want is to be able to modify the IL code in Interop assemblyt so that the signature looks like this:
VB
public void GetGroupsConfirmation (
           tcsGroupAttributes3_t [] groupAttributes3List, // here are the first two parameters are replaced with an array. 
           tcsBoolean_t endOfCollection, 
           Short cookie)

This solution requires that the IL code using groupAttributesListSize that size on a SAFE ARRAY (?) And fills the array with the elements included in the IL code.

These ideas we have
We have managed to change the signature in the IL code into an array so that we have an array even in .NET. The problem is I do not know how to get the size of the array is set to the number specified by the first parameter. However, I can specify the size of the array in the IL code.
Ideally, we would like that the array size to the number who actually are.

Does anyone know how to change the IL code so that we get back the list of elements in a SAFE ARRAY?
Posted
Updated 8-Sep-14 21:43pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900