reactive: Cannot compile Xamarin Android project with System.Reactive v4.1.0
Description
The new dependency System.Threading.Tasks.Extensions cannot be fully resolved on Xamarin Android projects. This is not a problem of Rx.NET but I’m leaving this here so other people can see it.
How to reproduce:
- Create a Xamarin Android project
- Add the System.Reactive nuget package version 4.1.0
- Compile and run.
Expected result An application running
Actual result
An exception is thrown:
Severity Code Description Project File Line Suppression State Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. Perhaps it doesn't exist in the Mono for Android profile? File name: 'System.Threading.Tasks.Extensions.dll' at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(DirectoryAssemblyResolver resolver, ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel) at Xamarin.Android.Tasks.ResolveAssemblies.Execute(DirectoryAssemblyResolver resolver) Poi.RxStte
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 19
- Comments: 71 (17 by maintainers)
Commits related to this issue
- Fix Android build break (Cannot find System.Threading.Tasks.Extensions) with workaround (https://github.com/dotnet/reactive/issues/803#issuecomment-427457135). — committed to notsure2/manglesocks by notsure2 6 years ago
- Moved the VMs to a separed project HACK: https://github.com/dotnet/reactive/issues/803 — committed to reactiveui/ReactiveUI by giusepe 5 years ago
- Moved the VMs to a separed project HACK: https://github.com/dotnet/reactive/issues/803 — committed to reactiveui/ReactiveUI by giusepe 5 years ago
The root cause is in package System.Threading.Tasks.Extensions there are no dll’s in the targets other than NetStandard2.0
A temporary resolution for System.Reactive 4.1.0 and 4.1.1 could be to add the following to your project file manually setting the desired version of System.Reactive as required
Hope this helps
Downgrading System.Threading.Tasks.Extension from 4.5.1 to 4.4.0 worked for me. Using:
All release versions of VS 2019 (including for Mac) should come with a fixed version of Xamarin.Android now, I think this can be considered solved now.
Sadly, GitHub doesn’t allow marking comments as answers or pinning them, but i’d like to note one more time, that Chris Pulman’s solution works for System.Reactive 4.1.0, 4.1.1 and also 4.1.2. I’m able to compile my ReactiveUI Xamarin.Android application using the setup he suggested (thanks!)
Put these lines into your
.csproj
file and it’ll work, no need to rollback to System.Reactive 4.0.x.@ahmedalejo In-box, at least in the Xamarin context, means that the deployed runtime got the necessary bits already bundled, so that a referenced nuget package may just omit any files for that platform. The System.Threading.Tasks.Extensions nuget in version 4.5.1 assumes the appropriate dlls be present on the Xamarin platform (in-box!), but they aren’t. It’s a bug, it’ll be fixed eventually, until that, downgrade to System.Threading.Tasks.Extensions 4.4.0 which is just fine.
Out of box means the opposite: The nuget has to provide the actual dlls, which is of course the case for most stuff on nuget.
Uhu! all day on this bug. Just downgraded System.Reactive to 4.0.0 and i´m good to continue
Thanks for holding this discussion, it helped a lot!
@onovotny could you please enlighten me about In-box and out of box that you mentioned about nuget packages?
It’s almost 2019 and the issue still persists.
I can still see the issue in an Azure DevOps build @danielcweber . My build uses the Xamarin.iOS task on my Xamarin.Forms solution but the error seems to be linked to the Android csproj.
My project uses 4.1.5 version of System.Reactive. Downgrading to version 4.0.0 works.
@sushihangover simply use the workaround, reference the 4.4 version in the Android project.
It’s been half a year!!! Can’t believe this issue still exists.
In my case, I use a mac, it is adding below into
.csproj
file@danielcweber: VS for Mac 7.6.7 (build 49) won’t let me have a dependency on
System.Threading.Tasks.Extensions 4.4.0
, when I haveSystem.Reactive 4.1.0
.I’m working on a Xamarin.Forms app, and the dependency problem is in the Packages for both Android and iOS projects (but no problems in our portable Xamarin projects).
Any suggestions for us Mac users?
@ahmedalejo As pointed out above, there is no need to downgrade Rx to 4.0. It is sufficient to take an excplicit dependency on System.Threading.Tasks.Extensions 4.4.0 in your top project.
What worked for me was keeping System.Threading.Tasks.Extensions upgraded, installing System.Runtime.CompilerServices.Unsafe to all android, ios, and uwp projects, and downgrading System.Reactive to version 4.0.0
According to https://github.com/xamarin/xamarin-android/commit/bf2b59ce6ea13640668dd6385ef287938d2628d7, the fix is included in the following versions of Xamarin.Android:
From this, I can’t see the fix being included in any version of VS 2017 (15.x). Therefore, please upgrade to VS 2019.
I will close this issue for now. If anybody sees the issue still persisting despite using the latest version of Visual Studio 2019 and Xamarin.Android, leave a note and detailed version information.
Yes, using System.Reactive 4.1.2 and by adding the reference to System.Threading.Tasks.Extensions 4.4.0 it works. Thanks.
I hope this year XD will be a fix for this issue
I am using the Hosted Visual Studio 2019 agent but I don’t know which precise version of Visual Studio 2019 is installed in this Hosted agent and when this version is updated by Microsoft.
It’s still there reactiveui -Version 9.15.1 VS 15.9.11
Severity Code Description Project File Line Suppression State Error Can not resolve reference:
System.Threading.Tasks.Extensions
, referenced bySystem.Reactive
. Please add a NuGet package or assembly reference forSystem.Threading.Tasks.Extensions
, or remove the reference toSystem.Reactive
.According to https://docs.microsoft.com/de-de/xamarin/android/release-notes/9/9.2, it is fixed in Xamarin.Android 9.1.103.7 which comes with Visual Studio 2019 Preview 2.
Any other solution than referencing the old 4.4.0 version ? Since 6 months ? Noone uses Reactive in Xamarin ?
If you want the most repeatable thing, just add the dlls to your repo and put in a path to the local copy:
james@DESKTOP-5ICP5OV:/mnt/c/Users/james/source/repos/App3$ tree binaries/ binaries/ └── netstandard2.0
├── System.Runtime.CompilerServices.Unsafe.dll
└── System.Threading.Tasks.Extensions.dll
Also, $(UserProfile) is a weird nonstandard windows hack, so you’ll need to add your weird nonstandard Macos hack too -
@godrose this issue is completely external to us and is something with VSfM/Xamarin. Unfortunately there’s little we can do.
/cc @unniravindranathan
Have you tried the latest version of VSfM/Xamarin?
@jonpryor I tried with 15.8 stable:
Our error message is a lot better now, this is from the error pad.
What is weird about this, is the System.Reactive NuGet has a dependency on System.Threading.Tasks.Extensions, why isn’t it installed?
When I look at the build log, the NuGet MSBuild task, has outputs:
@DrQwertySilence when I manually install
System.Threading.Tasks.Extensions
(Version 4.4.0, not the newest!) it fixes it. Does this work for you?