Resolution when it is not possible to cast COM object of type 'System.__ComObject' to interface type "System.Runtime.InteropServices.ComTypes.IConnectionPointContainer."
- Try to understand the process and use case.
- Isolate the Excel file and verify whether the Excel Application Scope is present inside the scope of a loop.
- Add the Close workbook activity in each iteration.
-
Call the garbage collectors explicitly in the code in the places where the crash was encountered and also at the end of the code
- Use Invoke Method activity - Set target type as - System.GC, Use Method Name - Collect
- Use Invoke Method activity - Set target type as - System.GC, Use Method Name - WaitForPendingFinalizers
- Use Invoke Method activity - Set target type as - System.GC, Use Method Name - Collect
- Add the Kill process activity (User level) in each iteration and reopen the Excel in the next iteration.
- Add a delay of 1-2 seconds right after the Excel Application Scope