Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile Xamarin Android project with System.Reactive v4.1.0 #803

Closed
DrQwertySilence opened this issue Aug 14, 2018 · 71 comments
Closed

Comments

@DrQwertySilence
Copy link

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:

  1. Create a Xamarin Android project
  2. Add the System.Reactive nuget package version 4.1.0
  3. 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

@akarnokd
Copy link
Collaborator

@jonpryor
Copy link
Member

@DrQwertySilence: Could you please provide the diagnostic MSBuild log output or a .binlog file?

The most likely cause is that System.Threading.Tasks.Extensions.dll isn't part of the @(Reference) item group.

Which version of Xamarin.Android are you using?

@DrQwertySilence
Copy link
Author

DrQwertySilence commented Aug 14, 2018

@jonpryor:

  1. Sure: https://drive.google.com/file/d/1y2vQcwsptkBnsP1RiqtuXblfADnBZL5Q/view?usp=sharing
    Part 1: https://gist.github.com/DrQwertySilence/dffa5693fc8dcb85336a5cce44c30cc9
    Part 2: https://gist.github.com/DrQwertySilence/93a7fa14a6904de272c9e25f9f79533a
  2. The version of Xamarin Android is 8.3.3.2

Is there some good online service to upload and review log files? Google Drive 🤦‍♂️

@jonpryor
Copy link
Member

@DrQwertySilence: The FileNotFoundException -- which is admittedly a terrible error, and has been improved in Xamarin.Android 9.0 -- results because of this build warning:

1>  Dependency "System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". (TaskId:24)
1>      Could not resolve this reference. Could not locate the assembly "System.Threading.Tasks.Extensions, Version=4.2.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. (TaskId:24)

followed by a long list of places MSBuild looked for System.Threading.Tasks.Extensions.dll, but couldn't find.

@jonathanpeppers
Copy link
Member

@jonpryor I tried with 15.8 stable:

Can not resolve reference: `System.Threading.Tasks.Extensions`, referenced by `System.Reactive`. Please add a NuGet package or assembly reference for `System.Threading.Tasks.Extensions`, or remove the reference to `System.Reactive`.	App38	C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets

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:

ResolveNuGetPackageAssets

_ReferencesFromNuGetPackages
    %UserProfile%\.nuget\packages\system.reactive\4.1.0\lib\netstandard2.0\System.Reactive.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = System.Reactive
        NuGetPackageVersion = 4.1.0
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.arch.core.common\1.0.0.1\lib\MonoAndroid80\Xamarin.Android.Arch.Core.Common.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Arch.Core.Common
        NuGetPackageVersion = 1.0.0.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.arch.lifecycle.common\1.0.3.1\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Common.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Arch.Lifecycle.Common
        NuGetPackageVersion = 1.0.3.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.arch.lifecycle.runtime\1.0.3.1\lib\MonoAndroid80\Xamarin.Android.Arch.Lifecycle.Runtime.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Arch.Lifecycle.Runtime
        NuGetPackageVersion = 1.0.3.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.animated.vector.drawable\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Animated.Vector.Drawable.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Animated.Vector.Drawable
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.annotations\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Annotations.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Annotations
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.compat\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Compat.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Compat
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.core.ui\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Core.UI.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Core.UI
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.core.utils\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Core.Utils.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Core.Utils
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.design\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Design.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Design
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.fragment\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Fragment.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Fragment
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.media.compat\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Media.Compat.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Media.Compat
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.transition\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Transition.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Transition
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.v7.appcompat\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.AppCompat.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.v7.AppCompat
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.v7.recyclerview\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.v7.RecyclerView.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.v7.RecyclerView
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false
    %UserProfile%\.nuget\packages\xamarin.android.support.vector.drawable\27.0.2.1\lib\MonoAndroid81\Xamarin.Android.Support.Vector.Drawable.dll
        NuGetIsFrameworkReference = false
        NuGetPackageId = Xamarin.Android.Support.Vector.Drawable
        NuGetPackageVersion = 27.0.2.1
        NuGetSourceType = Package
        Private = false

@DrQwertySilence when I manually install System.Threading.Tasks.Extensions (Version 4.4.0, not the newest!) it fixes it. Does this work for you?

@jonathanpeppers
Copy link
Member

System.Threading.Tasks.Extensions 4.5.1 has a dependency on System.Runtime.CompilerServices.Unsafe for NetStandard2, I wonder if this is somehow the problem...

@clairernovotny
Copy link
Member

The package has an empty folder for Xamarin and thus expects those types to be in-box. No references are added by the package there:

image

@clairernovotny
Copy link
Member

With the v4.4 version, it is out of box and installs:

image

With 4.5/4.5.1, it's in-box.

@jonathanpeppers
Copy link
Member

Ok related issue: dotnet/android#1879

Exact same System.Threading.Tasks.Extensions causing the problem...

@jonathanpeppers
Copy link
Member

Ok, there is a new facade assembly for System.Threading.Tasks.Extensions in mono-2018-06: mono/mono#9968

I think the plan is to get a newer mono in the next VS release.

I need to see if the workaround of using System.Threading.Tasks.Extensions 4.4 crashes at runtime.

@clairernovotny
Copy link
Member

clairernovotny commented Aug 15, 2018

Given that VS just shipped 15.8, waiting for the next release will cause a world of pain. We really need this in a 15.8.x bugfix release ASAP.

Users are hitting issues due to these missing assemblies already, particularly due to ValueTask living in that façade.

@jonathanpeppers
Copy link
Member

This terrible code isn't crashing for me at runtime (using 4.4.0 System.Threading.Tasks.Extensions):

public async Task<int> SlowAdd (int x, int y)
{
	var observableX = SlowInt (x).ToObservable ();
	var observableY = SlowInt (y).ToObservable ();

	return await observableX.Zip (observableY, (_x, _y) => _x + _y);
}

public async Task<int> SlowInt (int x)
{
	await Task.Delay (1);
	return x;
}

This should be calling into System.Threading.Tasks.Extensions, right?

In the meantime, I'll see if I can find the right people to ask about this.

@DrQwertySilence
Copy link
Author

@jonathanpeppers Sorry, I do not have access to a computer atm.

@jonathanpeppers
Copy link
Member

Filed on the mono side: mono/mono#10142

@DrQwertySilence
Copy link
Author

@jonathanpeppers What I have tried:

  • If you downgrade System.Threading.Tasks.Extensions to version 4.4.0 from the Visual Studio's [Manage NuGet Packages...] option it downgrades System.Reactive to version 4.0.0 too
  • if you do it editing the package.config file manually and do a full cleanup the same FileNotFoundException happens.

@jonathanpeppers
Copy link
Member

@DrQwertySilence I was using <PackageReference /> (a new project) but I am not sure why it didn't downgrade me?

<PackageReference Include="System.Reactive" Version="4.1.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.4.0" />

I used the NuGet dialogs in VS Windows.

Hopefully, we'll get something from the mono team.

@clairernovotny
Copy link
Member

@DrQwertySilence at the very least, migrate away from packages.config it's nothing but pain and everything supports PackageReference now. The latest VS versions have a "migrate to PackageReference" on the context menu of the packages.config file too.

@DrQwertySilence
Copy link
Author

@jonathanpeppers @onovotny Yup, that did the trick.

Thank you very much people.

@banshee
Copy link

banshee commented Aug 16, 2018

Not only is there not a context menu for packages.config, packages.config doesn't even show up in the solution, so it can't possibly have a context menu. At least on 7.6 Preview (7.6 build 2086).

@clairernovotny
Copy link
Member

That context menu is in Visual Studio for Windows. The Mac version does not have that migration utility currently.

@PureWeen
Copy link
Member

PureWeen commented Aug 21, 2018

Not sure if it's related to this but I'm having a lot of issues with Rx 4.1.0 and then downgrading Tasks.Extensions to 4.4.0 so that Android compiles..

Zip seems to be totally broken in some cases.

Enumerable.Range(0, 100)
				.Select(_ => Observable.Return(Unit.Default))
				.Zip()
				.Subscribe(_ =>
				{

				}
				);

causes the following exception on Android

08-21 04:39:18.069 I/MonoDroid(20153): UNHANDLED EXCEPTION:
08-21 04:39:18.074 I/MonoDroid(20153): System.NullReferenceException: Object reference not set to an instance of an object.
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Linq.ObservableImpl.Zip`1+_[TSource].OnCompleted (System.Int32 index) [0x0002f] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Linq.ObservableImpl.Zip`1+_+SourceObserver[TSource].OnCompleted () [0x00000] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Linq.ObservableImpl.ReturnImmediate`1[TSource].Run (System.IObserver`1[T] observer) [0x0000c] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.BasicProducer`1[TSource].SubscribeRaw (System.IObserver`1[T] observer, System.Boolean enableSafeguard) [0x00052] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.ObservableExtensions.SubscribeSafe[T] (System.IObservable`1[T] source, System.IObserver`1[T] observer) [0x00036] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Linq.ObservableImpl.Zip`1+_[TSource].Run (System.Collections.Generic.IEnumerable`1[T] sources) [0x00061] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Linq.ObservableImpl.Zip`1[TSource].Run (System.Reactive.Linq.ObservableImpl.Zip`1+_[TSource] sink) [0x00000] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Producer`2+<>c[TTarget,TSink].<SubscribeRaw>b__1_0 (System.ValueTuple`2[T1,T2] tuple) [0x00000] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Concurrency.Scheduler+<>c__75`1[TState].<ScheduleAction>b__75_0 (System.Reactive.Concurrency.IScheduler _, System.ValueTuple`2[T1,T2] tuple) [0x00000] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Concurrency.CurrentThreadScheduler.Schedule[TState] (TState state, System.TimeSpan dueTime, System.Func`3[T1,T2,TResult] action) [0x0004e] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Concurrency.LocalScheduler.Schedule[TState] (TState state, System.Func`3[T1,T2,TResult] action) [0x0000e] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Concurrency.Scheduler.ScheduleAction[TState] (System.Reactive.Concurrency.IScheduler scheduler, TState state, System.Action`1[T] action) [0x00024] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Producer`2[TTarget,TSink].SubscribeRaw (System.IObserver`1[T] observer, System.Boolean enableSafeguard) [0x00052] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.Reactive.Producer`2[TTarget,TSink].Subscribe (System.IObserver`1[T] observer) [0x0000e] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at System.ObservableExtensions.Subscribe[T] (System.IObservable`1[T] source, System.Action`1[T] onNext) [0x0002d] in <e0c8ecc985b349edb4fa04eaf38baae9>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at App3.MainActivity.OnCreate (Android.OS.Bundle savedInstanceState) [0x0008c] in d:\Documents\Visual Studio 2017\Projects\App3\App3\MainActivity.cs:38 
08-21 04:39:18.074 I/MonoDroid(20153):   at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState) [0x00011] in <46c5c71eacdc488bb6b4b2ba91dd3b0e>:0 
08-21 04:39:18.074 I/MonoDroid(20153):   at (wrapper dynamic-method) System.Object.10(intptr,intptr,intptr)

@akarnokd
Copy link
Collaborator

Can you reproduce this in the emulator?

@PureWeen
Copy link
Member

Yes

The attached project is just the basic Xamarin.Android template with System.Reactive installed and running a basic Zip operation

If I install just System.Reactive 4.1.0
Then I get this error

Severity	Code	Description	Project	File	Line	Suppression State
Error		Can not resolve reference: `System.Threading.Tasks.Extensions`, referenced by `System.Reactive`. Please add a NuGet package or assembly reference for `System.Threading.Tasks.Extensions`, or remove the reference to `System.Reactive`.	App3			

If I install 4.5.1 of Tasks.Extensions then I get the same error

If I downgrade, as was suggested above, to 4.4.0 then I'm able to compile and run in simulator but it crashes (this is the state of the attached sample)

App3.zip

If I just downgrade System.Reactive to 4.0.0 then it all runs fine and my Zip command succeeds

@danielcweber
Copy link
Collaborator

Seems like there's now good cause to merge #484, which I will after a rebase unless @akarnokd has this one fixed already...

I may have a look into this issue then.

@akarnokd
Copy link
Collaborator

I could reproduce the NullReferenceException in a non-xamarin project. I'll post a fix shortly.

@ajhuntsman
Copy link

Since Rx.NET 4.1.0 appears to contain so many fixes and improvements, we eagerly tried to upgrade our packages today (for 1 of our Xamarin apps), but could not compile after doing so (VS Mac 7.6.1 build 9):

error XA2002: Can not resolve reference: `System.Threading.Tasks.Extensions`, referenced by `System.Reactive`. Please add a NuGet package or assembly reference for `System.Threading.Tasks.Extensions`, or remove the reference to `System.Reactive`.

Of course, System.Threading.Tasks.Extensions was already included as a package, and updated to the latest version (4.5.1).

Thanks for looking into this!

@cvasquez-github
Copy link

Downgrading System.Threading.Tasks.Extension from 4.5.1 to 4.4.0 worked for me.
Using:

  • System.Reactive 4.1.0 (latest)
  • System.Reactive.Interfaces 4.1.0 (latest)
  • System.Reactive.Linq 4.1.0( latest)
  • System.Reactive.PlatformServices (latest)
  • System.Threading 4.3.0 (latest)
  • System.Threading.Taks 4.3.0 (latest)
  • System.Threading.Tasks.Extensions 4.4.0 (downgraded)

@natasha-tullos
Copy link

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

@banshee
Copy link

banshee commented Jan 23, 2019

As we use CI, so this won't work.

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 -

<ItemGroup>
  <Reference Include="System.Threading.Tasks.Extensions">
    <HintPath>$(UserProfile)$(HOME)\.nuget\packages\system.threading.tasks.extensions\4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
  </Reference>
</ItemGroup>

@softlion
Copy link

softlion commented Feb 4, 2019

Any other solution than referencing the old 4.4.0 version ? Since 6 months ? Noone uses Reactive in Xamarin ?

@justintoth
Copy link

I was using System.Reactive for handling "debounce" behavior... I ended up just using custom C# code to do it so that I could remove the System.Reactive nuget package from my project, as the 4.4.0 solution didn't resolve the issue for me.

@danielcweber
Copy link
Collaborator

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.

@sushihangover
Copy link

sushihangover commented Feb 6, 2019

@danielcweber 😢 Unfortunately VS4M Preview 2 comes with Xamarin.Android Version: 9.1.5.1 and thus is still broken. So no Reactive/ReativeUI for this new project, I cannot wait for another preview release and the client will not accept working with anything not on the "stable" channel...

re: dotnet/android#1879

@softlion
Copy link

softlion commented Feb 6, 2019

@sushihangover simply use the workaround, reference the 4.4 version in the Android project.

@endymion00
Copy link

@sushihangover simply use the workaround, reference the 4.4 version in the Android project.

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

giusepe added a commit to reactiveui/ReactiveUI that referenced this issue Feb 15, 2019
glennawatson pushed a commit to reactiveui/ReactiveUI that referenced this issue Mar 15, 2019
@MichellemBettecourt
Copy link

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

<ItemGroup>
    <PackageReference Include="System.Reactive" Version="4.1.1" />
    <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.2"/>
  </ItemGroup>
  <ItemGroup>
    <Reference Include="System.Threading.Tasks.Extensions">
      <HintPath>$(UserProfile)\.nuget\packages\system.threading.tasks.extensions\4.5.1\lib\netstandard2.0\System.Threading.Tasks.Extensions.dll</HintPath>
    </Reference>
  </ItemGroup>

Hope this helps

Where exactly do you add this? Do I add it to the line visual studio is telling me the error occurs?

For reference, this is my error. It is in Xamarin.Android.Common.Targets.

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error XA2002: Can not resolve reference: System.Threading.Tasks.Extensions, referenced by Carbon.Data.Protection. Please add a NuGet package or assembly reference for System.Threading.Tasks.Extensions, or remove the reference to Carbon.Data.Protection. (XA2002)

@Tmaturano
Copy link

I tried the steps that you guys commented above, it builds Ok, but when I run the project and access a Page that uses the Reactive, the app Crashes using VS 2019.
If I use VS 2017, it works.
System.Reactive V4.1.2 in the Cross Project and Android Project
System.Threading.Tasks.Extensions V4.4.0 in Android project

@godrose
Copy link

godrose commented Apr 3, 2019 via email

@Tmaturano
Copy link

Nevermind guys, it's the AutoSuggestBox Plugin that is breaking with VS 2019.
Reactive is working fine.
Thanks

@danielcweber
Copy link
Collaborator

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.

@glennawatson
Copy link

Have some reports this is still happening with VSfM 2019 (8.0 build 1805) for the RXUI project. See reactiveui/ReactiveUI#1955

@giusepe
Copy link

giusepe commented May 13, 2019

It's now working for me: reactiveui/ReactiveUI#1955 (comment)
I think it's safe to close the issue now.

@KennyDizi
Copy link

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 by System.Reactive. Please add a NuGet package or assembly reference for System.Threading.Tasks.Extensions, or remove the reference to System.Reactive.

@danielcweber
Copy link
Collaborator

danielcweber commented May 14, 2019

According to dotnet/android@bf2b59c, the fix is included in the following versions of Xamarin.Android:

grafik

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.

@TechWatching
Copy link

TechWatching commented May 16, 2019

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.

error XA2002: Can not resolve reference: System.Threading.Tasks.Extensions, referenced by System.Reactive. Please add a NuGet package or assembly reference for System.Threading.Tasks.Extensions, or remove the reference to System.Reactive.

My project uses 4.1.5 version of System.Reactive. Downgrading to version 4.0.0 works.

@danielcweber
Copy link
Collaborator

@TechWatching What's relevant is the version of Visual Studio used in the build.

@TechWatching
Copy link

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.

@DevEddy
Copy link

DevEddy commented May 17, 2019

Same issue with Visual Studio Community 2019 for Mac Version 8.0.6 (build 4).

@TechWatching
Copy link

My Azure DevOps build that fails is the iOS Build so the agent I use is the Hosted macOS High Sierra agent (and not the Hosted VS 2019 agent as I was saying, sorry my bad).

The version of VS on this agent is Visual Studio for Mac: 8.0.5.9

@danielcweber I guess the correction was shipped to Visual Studio 2019 but maybe not to Visual Studio for Mac yet, don't you think ?

@glennawatson
Copy link

Might be worth chasing up on Azure DevOps about that one having a Hosted Agent with VSfM 9 support. Given it's been released it's a reasonable thing to have it available.

@danielcweber
Copy link
Collaborator

Can anybody look up the actual Xamarin.Android version that gets installed with VSfM 8.0.5.9?

@glennawatson
Copy link

@glennawatson
Copy link

So given the newest is 9.2.3-0 on the hosted agent, and it's fixed in 9.3.0.19.

https://github.com/microsoft/azure-pipelines-image-generation/pull/895

According to that they pushed out 9.2.3-0 18 days ago, it takes about 3 weeks for the images to hit the servers according to https://github.com/microsoft/azure-pipelines-image-generation/pull/770#issuecomment-492656299

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests