Unhandled managed exception: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Expected dequeued view to be returned to the collection view in preparation for display.

I'm getting a crash wherever I've used the Collection view in my app with this exception:

Unhandled managed exception: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Expected dequeued view to be returned to the collection view in preparation for display. When the collection view's data source is asked to provide a view for a given index path, ensure that a single view is dequeued and returned to the collection view. Avoid dequeuing views without a request from the collection view. For retrieving an existing view in the collection view, use -[UICollectionView cellForItemAtIndexPath:] or -[UICollectionView supplementaryViewForElementKind:atIndexPath:]. Dequeued view:

It not built with native Swift or Xcode, instead it's a .Net MAUI app for iOS and it's crashing only on iOS 18+ and working absolutely fine on all other versions below iOS 18. I've not used any dequeuing of cells or any such code as it is not a native code, it's C# code and I'm just using template selector for designing different cells of collection view, so I'm not getting any fix for this exception as how to fix this dequeuing problem when I don't even have any such native code. Has anyone fixed this issue or find a solution for it yet?

Same here, works fine on Android as usual.

Same issue and none of the given online solutions work. Have you found a solution for this yet?

Hi @NidhiSood9 I have found a solution to this problem. All I had to do to get this to work is to add a few packages to the main project csproj.

These are the packages that I added: <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.92" /> <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.92" /> <PackageReference Include="Microsoft.Maui.Controls.Core" Version="8.0.92" /> <PackageReference Include="Microsoft.Maui.Controls.Xaml" Version="8.0.92" /> <PackageReference Include="Microsoft.Maui.Controls.Build.Tasks" Version="8.0.92" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />

Once you’ve added these packages, do a clean, delete bin and obj, launch visual studio, build the project and run it.

This resolved my Collectionview IsGrouped issue for iOS 18.0, I hope it resolves yours too.

Unhandled managed exception: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: Expected dequeued view to be returned to the collection view in preparation for display.
 
 
Q