I'm trying to use the new Rx.NET 3.0 version with Xamarin.Android but I'm getting a compile error after installing the packages. The error message is:
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Projects\NS\Kanzi.Mobile\packages\System.Runtime.InteropServices.WindowsRuntime.4.0.1\lib\netstandard1.3\System.Runtime.InteropServices.WindowsRuntime.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\System.Runtime.InteropServices.WindowsRuntime.dll'. Remove one of the duplicate references. Mobile.Core.Android C:\Projects\NS\Kanzi.Mobile\Mobile.Core.Android\CSC 1 Active
I can see the reference to the System.Runtime.InteropServices.WindowsRuntime assembly from the associated package in my projects reference. Not sure where the other assembly comes from, but I'm assuming this is included automagically by the build system.
Is this supposed to work at all? I'm using the latest stable Xamarin version (4.1.2.18) and Xamarin.Android version (6.1.2.21) with Visual Studio 2015 Update 3.
I'm really not sure what's happening here, both of these packages seem to be external to System.Reactive:
- 'C:\Projects\NS\Kanzi.Mobile\packages\System.Runtime.InteropServices.WindowsRuntime.4.0.1\lib\netstandard1.3\System.Runtime.InteropServices.WindowsRuntime.dll'
- 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\System.Runtime.InteropServices.WindowsRuntime.dll'
Can you tell me:
NuGet Package Manager you have installed in VS2015?project.lock.json file in the project folder, please attach the contents so we can see what might be responsible for this System.Runtime.InteropServices.WindowsRuntime dependencyI was installing System.Reactive 3.0.0. When I install that package I get the following dependencies for free:
System.Collections.4.0.11
System.Collections.Concurrent.4.0.12
System.ComponentModel.4.0.1
System.Diagnostics.Debug.40.11
System.Diagnostics.Tools.4.0.1
System.Globalization.4.0.11
System.Linq.4.1.0
System.Reactive.Interfaces.3.0.0
System.Reflection.4.1.0
System.Resources.ResourceManager.4.0.1
System.Runtime.4.1.0
System.Runtime.Extensions.4.1.0
System.Runtime.InteropServices.WindowsRuntime.4.0.1
System.Threading.4.0.11
System.Threading.Tasks.4.0.11
System.Reactive.Core.3.0.0
System.Reactive.Linq.3.0.0
System.Reactive.PlatformServices.3.0.0
System.Reactive.3.0.0
As you can see that list includes the System.Runtime.InteropServices.WindowsRuntime package which is where things start to fail.
I'm using version 3.5.0.1484 of the NuGet package explorer. Unfortunately I do not have a project.lock.json file since I'm not using the project.json/xproj project system but using regular csproj's.
Here's your problem dependency - hiding inside System.Reactive.Linq.
Unfortunately I'm really rusty on the Xamarin side of things and whether the facade is still correct to be using here. Hopefully someone else has some ideas here.
Well, I tried removing the reference to the assembly from the package, but then a release build fails with a linker error, probably because something in System.Reactive depends on a type that is defined in that assembly which does not exist in the facade assembly. Not sure if I can try it the other way around (removing the Facade assembly from the mix) and see if that works.
That System.Runtime.InteropServices.WindowsRuntime assembly is part of the PCL 259 fa莽ade/surface area and Xamarin does support it (there's no real implementation there, it's just a few types).
Do you have a repro project as it should work? I would recommend using project.json for all project types, including Xamarin, as it works better and may solve your issue. My blog shows how: https://oren.codes/2016/02/08/project-json-all-the-things/
I just created a brand new Android Class Library project and installed the System.Reactive 3.0.0 package into it and I get the compile error. You can find the sources here.
We've downgraded to the Rx-Main 2.2.5 package for now. I'll need to have a look at converting this to project.json since I had some issues with that in the past, especially with creating a NuGet package from a project that has project.json.
@jmezach I am ignorant about xamarin. However I have just updated DynamicData (which is portable and depends on rx) to NetStandard and was looking for a quick way to test it with xamarin.
In short I had the same problem until I downloaded and tested it using SampleXamFormsWithNetStandard. The correct way to use xamarin with NetStandard is explained here. However moving to NetStandard may not be what you want right now.
@onovotny FYI I had the following build error: The "CreateAdditionalLibraryResourceCache" task failed unexpectedly. It turns out this is caused by a long file path which I had to shorten. I mention this in case anyone else gets the same problem
Same problem as you have. Xamarin.iOS, .NET and UWP library projects has no problem but the Xamarin.Android give me the same error when I compile...
We were hoping that previous NuGet problems were solved with latest Xamarin bits and we could move to 3.0.0 - but, no, we are seeing this error in Xamarin Android projects. Not sure who needs to fix what, but have logged report with Xamarin:
I believe the problem lies with the System.Runtime.InteropServices.WindowsRuntime nuget package, it doesn't contain an empty definition for Xamarin.Android, but does for Xamarin.iOS.
This line seems interesting but I'm unclear on how the packaging of the corefx bits works to confirm this is where we need to address it 馃槙
I just bugged it here: https://github.com/dotnet/corefx/issues/12070. Not sure what the right answer is gien that Xamarin does support .NET Standard 1.6 and is thus pulling in the netstandard1.3 package.
Can anyone experiencing this issue please follow the directions here https://github.com/dotnet/corefx/issues/12070#issuecomment-249617241 and use the latest pre-release of the .NET Standard Library to validate the fix?
@onovotny The pre-release did not fix the error for me.
We are experiencing the same problem in our Xamarin Android solution.
We are using Reactive Extensions version 3.0.0 and have just removed the reference to "System.Runtime.InteropServices.WindowsRuntime" from our projects.
Then we got those linker errors.
IMPORTANT: in order to get those errors, you have to uncheck "Use Shared Runtime" in packaging properties. The reason seems to be that if that is checked, Xamarin does not ship the Mono Runtime packages with your apk but installs them separately, so other (debug versions of) apps can also use it. As it is shared, the linker also does not try to reduce its size, so no linking on SDK assemblies is done.
Now when we run the build, we got the linker error:
The "LinkAssemblies" task failed unexpectedly.
Java.Interop.Tools.Diagnostics.XamarinAndroidException: error XA2006: Reference to metadata item 'System.Collections.Concurrent.ConcurrentQueue`1' (defined in 'System.Reactive.Linq, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263') from 'System.Reactive.Linq, Version=3.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263' could not be resolved. ---> Mono.Cecil.ResolutionException: Failed to resolve System.Collections.Concurrent.ConcurrentQueue`1
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkField(FieldReference reference)
at Mono.Linker.Steps.MarkStep.InitializeFields(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeType(TypeDefinition type)
at Mono.Linker.Steps.MarkStep.InitializeAssembly(AssemblyDefinition assembly)
at Mono.Linker.Steps.MarkStep.Initialize()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
--- End of inner exception stack trace ---
at Java.Interop.Tools.Diagnostics.Diagnostic.Error(Int32 code, Exception innerException, String message, Object[] args)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Interestingly, the linker error only occurered with the option "SKD Assemblies only".
If you specify "None", then linking is disabled and no error occurs. That makes totally sense.
What supprised us was, that the option "SDK and user assemblies" did work too!
In order to find out, what dll really caused the problem, we sticked to the "SDK and user assemblies" option and added the names of all our own assemblies AND all referenced assemblies to the "Skip linking assemblies:" textbox.
This was done as we needed to be sure that none of our own assemblies and none of the assemblies that we were referencing from nuget packages.
Now as soon as we removed the "System.Reactive.Linq" name from that "Skip linking assemblies" textbox, the error reoccurred.
So what we think is going on, is that the Xamarin Linker removes the part of System.Reactive.Linq that causes the error.
But what I guess is that the error is more likely to be in Xamarin itself, as its linker should notice, that System.Reactive.Linq is actually referencing the System.Collections.Concurrent.ConcurrentQueue class and should not remove it....
The worst thing of all is that I tried to create a sample solution for you guys to help you reproduce the error, but for some reason, the error does not occur in our test project...
Update: We actually fixed the build now!
The only thing we did, was to migrate from nuget.config to project.json.
That changed two things:
1) The reference to System.Runtime.Windows.in now worked (so we did not have to remove it manually)
2) The linker error vanished completely, even if we switched the linker back to "SDK Assemblies only" which originally caused the error.
Who thinks about migrating, read this first: https://oren.codes/2016/02/08/project-json-all-the-things/
...and then in the original documentation.... (https://github.com/NuGet/Home/wiki/Converting-a-csproj-from-package.config-to-project.json)
...at the very bottom of the page, you'll find the link to a powershell script (https://github.com/wgtmpeters/nugetprojectjson) which does most of the migration work for you! (We had 40 projects in our solution and finished in 3 hours)
@gentledepp Good to hear you got it working. Actually removing the reference to 'System.Runtime.InteropServices.WindowsRuntime' was enough to get things working for us, we didn't get those linker errors for some reason, even though we do use Link SDK and Assemblies.
This is somehow working for me as well! 馃帀
@gentledepp that's excellent news, thanks for helping get to the bottom of it!
As it sounds like there's a couple of workarounds in here, I'm going to close this out :tada:
Feel free to comment again if you see variations on this.
Hey, I'm late to the party here.
Microsoft is phasing out project.json and reintroducing .csproj files. And the issue is back.
Any known workaround for the new form of projects?
wooohow.... again I was proven right to wait for some time before switching to the lates version of VS :-|
So no, unfortunately not ;-)
@aspyct @gentledepp please open a new issue with more information about what you're seeing
@aspyct I had this problem working on Xamarin.Forms project and the solution of gentledepp didn't work forme. It looks like updating the System.Runtime.InteropServices.WindowsRuntime to v4.3.0 fixed the issue in my case.
Although I'm using VS for Mac, it can't hurt you to try it out.
@aspyct just wanted to chime in and say jpozo20's suggestion for upgrading to System.Runtime.InteropServices.WindowsRuntime to v4.3.0 also worked for me. Xamarin Community Studio on Mac
Updating to System.Runtime.InteropServices.WindowsRuntime to v4.3.0 , its worked for me ..
i am using System.Runtime.InteropServices.WindowsRuntime 4.3.0 but it doesnt work after migrating packages.config. any other solution please? i am getting.
Severity Code Description Project File Line Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void System.StreamMixins/<>c__DisplayClass0_0::<WriteAsyncRx>b__0(System.IAsyncResult)'
in assembly: 'Akavache.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Reactive.Subjects.SubjectBase`1
at Mono.Linker.Steps.MarkStep.HandleUnresolvedType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkType(TypeReference reference)
at MonoDroid.Tuner.MonoDroidMarkStep.MarkType(TypeReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessPrimaryQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
Most helpful comment
@aspyct just wanted to chime in and say jpozo20's suggestion for upgrading to System.Runtime.InteropServices.WindowsRuntime to v4.3.0 also worked for me. Xamarin Community Studio on Mac