The proper signature for this would be like so:
void Next(
uint celt,
[Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex=0)] IFoo[] rgelt,
out uint pceltFetched);
According to MSDN, at least, there's no mechanism to generate this automatically. Even if the original IDL for the interface had length_is
applied to rgelt
, that information is lost in the typelib. So you'll need to edit the interop assembly manually.
One other option is to define this particular interface entirely by hand in your main assembly, and simply ignore the generated interop version. Remember that when doing casts on RCWs, any interface with a matching GUID (i.e. the one for which QueryInterface is successful) will work, so you can actually have several different managed interfaces that present differing views of the same COM interface.