I am calling an externally provided COM DLL for which I have generated a COM interop wrapper. For the sake of argument, let's call the interface I want to call IEnumFoo
.
IEnumFoo
has the typical COM enumerator pattern:
HRESULT Next (
ULONG celt,
IFoo** rgelt,
ULONG* pceltFetched
);
where the first parameter is the number of desired results, the second parameter is a buffer to which results are written, and the last parameter describes the number of results actually written.
When I choose "Add Reference" and point Visual Studio at this DLL, it generates a COM Interop Assembly with the following signature:
void Next(uint, out IFoo, out uint)
This only allows the .NET code to request a single object at a time, which can add a significant amount of overhead to using these APIs.
Is there some mechanism I can use to generate a version of Next
which would allow me to provide more IFoo
"slots" above which would make the marshaler happy? (I'm not averse to editing the IL in the interop assembly by hand :) )