SP2016 Application using BCS IEntityInstanceEnumerator

New Contributor
I have recently began re-work a custom .NET applications and have migrated it from .NET3.5 on SP2010 (dev on VS2010) to .NET4.52 on SP2016 (dev on VS2017). Everything has ported fairly seamlessly. However, I have been diagnosing an issue with the BCS data retrieval using the FindFiltered method into IEntityInstanceEnumerator (IEIE) interface. When the call completes, and the subsequent MoveNext call is executed, an error occurs indicating: External ItemEnumerator is closed The model I have imported and setup still contains all valid pieces and permissions...each item container ReadList and ReadItem operations. I'm now using Kerberos/Claims w/ valid SPNs setup. I can see the valid query call to SQL both in ULS logs and in SQL profiler. I have turned on VERBOSEX and retrieved no additional clues. The odd thing is in other parts of the application, if we push the returned IEIE into the CreateDataTable, we can process it seems the data exists. I'm trying not to have to refactor several areas if I can find a reason why this would be occurring. Thanks for any ideas (and I will provide more info as requested).
1 Reply
best response confirmed by Lignite (New Contributor)

FWIW: It was determined that the use of the using{} statement was the cause of the issue.  It was causing the disposal of the object that was being returned to be cleared before it could be used back in calling function.  It appears that this it was not fixed until .NET 4.5, which is why it did not "raise its ugly head" until now.  I have removed the using{} statement and moved to calling function in those particular areas and all is good now.