I'm developing a C# class library which calls functions and procedures in an ActiveX DLL developed in Delphi. For discussion sake, I'll refer to the Delphi DLL as Delphi.dll and the C# class library as CSharp.dll. A reference to Delphi.dll has been added to the C# project.
Delphi.dll includes a TCollection class, functions Get_Count(), Get_Item(), and procedures Add(), Remove(). CSharp.dll is able to call Get_Count(), Add() and Remove() without any issues, however a call to Get_Item() raises the following error:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Here's the declaration for Get_Item() in Delphi.dll:
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Here's an example of CSharp.dll calling Get_Item():
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
Where myCollection is type (Delphi.dll).Collection and I've tried declaring aRecord as type dynamic, object and (Delphi.dll).Collection.
I believe the error is due to Get_Item() returning type IDispatch, which C# does not know how to handle.
What modifications do I need to make in C# to resolve this issue?
	
		
			
		
		
	
				
			Delphi.dll includes a TCollection class, functions Get_Count(), Get_Item(), and procedures Add(), Remove(). CSharp.dll is able to call Get_Count(), Add() and Remove() without any issues, however a call to Get_Item() raises the following error:
			
				C#:
			
		
		
		Type: EIntfCastError
Message: Interface not supported
			
				C#:
			
		
		
		function TCollection.Get_Item(Index: OleVariant): IDispatch;
begin
  Result := fList.Items[ConvertIndex(Index)] as IDispatch;
end;
			
				C#:
			
		
		
		aRecord = myCollection.GetItem(1)I believe the error is due to Get_Item() returning type IDispatch, which C# does not know how to handle.
What modifications do I need to make in C# to resolve this issue?
			
				Last edited by a moderator: 
			
		
	
								
								
									
	
		
			
		
		
	
	
	
		
			
		
		
	
								
							
							 
	