I am using a .Net2.0 Assembly in Delphi 6 via COM. One of the methods in one of the interfaces returns IEnumerable. As long as I import mscorlib.tlb located in
‘C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727’
, I can reach both IEnumerable and IEnumerator interfaces in Delphi 6. Here is the part where IEnumerable is defined in mscorlib_TLB.pas:
// *********************************************************************// // Interface: IEnumerable // Flags: (4416) Dual OleAutomation Dispatchable // GUID: {496B0ABE-CDEE-11D3-88E8-00902754C43A} // *********************************************************************// IEnumerable = interface(IDispatch) ['{496B0ABE-CDEE-11D3-88E8-00902754C43A}'] function GetEnumerator: IEnumVARIANT; safecall; end;
The return value of the GetEnumerator method is not IEnumerator and when I try to cast it to IEnumerator ‘Interface not supported’ exception is thrown.
Has anyone encountered this or a similar problem before? How can it be resolved?
This is standard behavior when interacting with .NET objects through COM interop, as specified here:
http://msdn.microsoft.com/en-us/library/111chfb8(VS.71).aspx