首页 > android > Xamarin Forms Android这种类型的collectionView不支持从与调度程序线程不同的线程更改其sourceCollection

Xamarin Forms Android这种类型的collectionView不支持从与调度程序线程不同的线程更改其sourceCollection (Xamarin Forms Android This type of collectionView does not support changes to its sourceCollection f)

问题

这是我在尝试存档我的应​​用程序以进行部署时遇到的错误。

error on archive 此错误不会在任何其他时间出现。该项目可以毫无问题地在仿真器和设备上构建和运行。此错误的上下文或方向为零,以确定修复它的位置。它也随机地随机出现,上次我建立/存档(没有功能变化)这个错误没有发生。

这个档案和前一个档案的主要区别是VS 2017的新版本。不记得以前的版本,但目前在15.9.4(稳定)。

在互联网上四处看看,我发现这个错误似乎与ObservableCollection有关,我的应用程序中可能存在10-ish。不确定在这里做什么,因为这在以前从来就不是问题,而且我在截止日期和应用程序的结构上,我不能很好地开始进行功能更改。

编辑

我还清理并重建了我的解决方案,并删除了我的xamarin项目中的所有bin / obj文件夹。甚至尝试删除有时可以帮助的.vs文件夹。但仍然没有去。

要尝试将VS更新到15.9.5并查看它是否已在发布中修复。

编辑2

将VS 2017更新为15.9.5没有任何区别。

编辑3

我让我的同事尝试在他的机器上存档完全相同的项目(运行VS 2017:5.9.3,并且它存档很好。到目前为止,这是我们在环境之间找到的唯一区别。

解决方法

我使用VS2017 15.9.9看到了同样的问题。即使是一周前可以归档的相同代码也会引发上述错误。它似乎与解决方案中的本地数据有关。“清晰”的构建是不够的。但是,手动删除本地obj和bin文件夹,然后归档(构建是隐式完成的)解决了我的问题。

问题

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.

解决方法

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.

相似信息