Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xamarin Forms Android This type of collectionView does not support changes to its sourceCollection from a thread different from the dispatcher thread

Here is the error I'm getting when trying to archive my app for deployment.

error on archive This error doesn't show up at any other time. The project builds and runs on emulators and devices without issue. This error has zero context or direction as to where to look to fix it. It also just randomly showed up out of nowhere, last time I built/archived (with zero functional changes) this error did not happen.

Main difference between this archival and the previous one is a newer version of VS 2017. Don't remember exactly the version from before, but am currently on 15.9.4 (stable).

Looking around on the interwebs, I've found that this error seems to have something to do with ObservableCollection's, which there are probably 10-ish in my app. Not really sure what to do here, because this has never been an issue previously, and I'm coming up on a deadline and with the structure of the app, am not in a good position to start making functional changes.

EDIT

I have also cleaned and rebuilt my solution, as well as deleting all bin/obj folders in my xamarin projects. Even tried deleting the .vs folder which can sometimes help. But still no go.

Going to try updating VS to 15.9.5 and see if maybe it was fixed in a release.

EDIT 2

Updating VS 2017 to 15.9.5 made no difference.

EDIT 3

I had my coworker try archiving the exact same project on his machine (running VS 2017: 5.9.3, and it archived fine for him. So far that's the only difference we've been able to find between our environments.

like image 965
Nieminen Avatar asked Jan 18 '19 14:01

Nieminen


2 Answers

I saw the same problem using VS2017 15.9.9. Even the same code that could be archived a week ago threw the above mentioned error. It seems related to local data in the solution. A "clear" build was not sufficient. However manual deletion of the local obj and bin folders followed by archiving (build is done implicitly) solved the problem for me.

like image 193
Jomst Avatar answered Oct 01 '22 03:10

Jomst


For my part closing Visual studio and deleting the .vs hidden folder did it.

It's actually a fix for many issues using Xamarin.

I had this other issue where I couldn't archive because the build process would just hang and never end. Deleting the .vs folder did it too. https://github.com/xamarin/xamarin-android/issues/1760

like image 30
Sébastien Lemieux Avatar answered Oct 01 '22 03:10

Sébastien Lemieux