Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

[Bug] Incorrect version of System.Numerics.Vectors is installed

Open JanNepras opened this issue 5 years ago • 88 comments

Description

We are implementing our own internal nuget package using "Cross-Platform .NET Standard Library Plugin" template. In this project we would like to consume Xamarin.Essentials nuget package. Once Xamarin.Essentials is installed there is incorrect version of System.Numerics.Vectors (4.5.0 instead of 2.0.5.0) linked to project. When I try to retrieve data from accelerometer like this:

var x = e.Reading.Acceleration.X

I got the error: Error CS0012: The type 'Vector3' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Numerics, Version=2.0.5.0

I tried to install Xamarin.Essentials into Xamarin.Forms project and it installs correct version.

Steps to Reproduce

  1. Create project using "Cross-Platform .NET Standard Library Plugin" template
  2. Install Xamarin.Essentials into this project
  3. Implement Accelerometer_ReadingChanged event in any .apple.cs class
  4. Try to access coordinates in this event like this e.Reading.Accelration.X

Expected Behavior

The version of System.Numerics.Vectors should be 2.0.5.0

Actual Behavior

The version of System.Numerics.Vectors is 4.5.0

Basic Information

  • Version with issue: I tried all versions of Xamarin.Essentials
  • Last known good version: NA
  • IDE: Visual Studio 2017 and 2019

Screenshots

bug

JanNepras avatar Sep 12 '19 14:09 JanNepras

Additional info:

This is only happening in classes wih sufix apple.cs.

Sufixes uwp.cs, android.cs and shared.cs have linked version 4.5.0 and work.

JanNepras avatar Sep 16 '19 08:09 JanNepras

Can you please add a repro of your issue so we can take a look. Thanks!

jamesmontemagno avatar Sep 17 '19 06:09 jamesmontemagno

@jamesmontemagno I updated this ticket. Hopefully this is more clear now.

JanNepras avatar Sep 17 '19 13:09 JanNepras

Can you show me what your csproj looks like or attach a repro that we can use. It makes it much easier to debug.

jamesmontemagno avatar Sep 18 '19 17:09 jamesmontemagno

LibraryIssue.zip

JanNepras avatar Sep 23 '19 08:09 JanNepras

So, this is very strange as it doesn't seem to bring in the reference dependencies that we are specifying. @Redth we should look as to why we are bringing in the NuGet globally.... I think this is wrong.

A work around is to add this to your iOS Include:

    <Reference Include="System.Numerics" />
    <Reference Include="System.Numerics.Vectors" />

jamesmontemagno avatar Oct 06 '19 00:10 jamesmontemagno

I am seeing the same issue when building for Android:

/Library/Frameworks/Mono.framework/Versions/5.16.0/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(5,5): Warning MSB3277: Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. (MSB3277) (ExtraconTracker.Droid)

System.Numerics.Vectors 4.5.0 is installed when it needs 2.0.5.0

IDE: VS for Mac Community, 7.8.2b1 Xam.Essentials 1.3.1

iOS builds w/o the warning.

RobLut avatar Nov 13 '19 15:11 RobLut

I have the same issue for Android when building on a PC:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2110,5): warning MSB3277: Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

IDE: VS 2017, 15.9.16 Xam.Essential 1.3.1

fperez2511 avatar Dec 05 '19 01:12 fperez2511

Same warning here with Xamarin.Essentials version 1.3.1.

Visual Studio Details
Microsoft Visual Studio Community 2019
Version 16.4.0
VisualStudio.16.Release/16.4.0+29519.181
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA534
Microsoft Visual C++ 2019

.ignore   1.2.77
A language service that makes it painless to handle all types of .ignore files such as .gitignore, .tfignore, etc.

Add New File   3.5.134
The fastest and easiest way to add new files to any project - including files that start with a dot

ASP.NET and Web Tools 2019   16.4.457.38025
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0   16.4.457.38025
Azure App Service Tools v3.0.0

C# Tools   3.4.0-beta4-19569-03+82f2e2541478e239dc4b04f231e90dc2b3dcb422
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

CheckedExceptionsPackage Extension   1.0
CheckedExceptionsPackage Visual Studio Extension Detailed Info

CodeMaid   11.1.209
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

EditorConfig Language Service   1.17.260
Language service for .editorconfig files.

EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs.

Extensibility Message Bus   1.2.0 (d16-2@8b56e20)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

File Icons   2.7
Adds icons for files that are not recognized by Solution Explorer

FormatCommand Extension   1.0
FormatCommand Visual Studio Extension Detailed Info

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Line Press   13d97f3e-75e2-4715-a444-715b5f39f0a4
Control the line-height of code lines, and compress empty or any unimportant lines. Have best of both worlds, more code view with no cram.

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.0.87+gbb515bf382
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   16.5.23 (1b51e8c)
Support for debugging Mono processes with Visual Studio.

MoveTypeToFile   1.0
MoveTypeToFile

NamespaceFixer   2.6
VS Extension to fix namespaces following C# and VB.NET convention

NuGet Package Manager   5.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Open in Visual Studio Code   1.4.46
Adds a menu command that lets you open any solution, project, folder and file in Visual Studio Code.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Smart Command Line Arguments Extension   2.2.0
A Visual Studio Extension which aims to provide a better UI to manage your command line arguments. For additional information, visit https://github.com/MBulli/SmartCommandlineArgs

SQL Server Data Tools   16.0.61911.11100
Microsoft SQL Server Data Tools

SubwordNavigation   1.5.0
Provides subword navigation for Visual Studio.

TypeScript Tools   16.0.11031.2001
TypeScript Tools for Microsoft Visual Studio

Viasfora   4.2.188
Add color to your Visual Studio editor!

Visual Basic Tools   3.4.0-beta4-19569-03+82f2e2541478e239dc4b04f231e90dc2b3dcb422
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.4 for F# 4.6   16.4.0-beta.19556.5+e7597deb7042710a7142bdccabd6f92b0840d354
Microsoft Visual F# Tools 10.4 for F# 4.6

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview)   1.0
View, manage, and diagnose containers within Visual Studio.

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for CMake   1.0
Visual Studio Tools for CMake

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers

Visual Studio Tools for Unity   4.4.2.0
Visual Studio Tools for Unity

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSColorOutput   2.6.7
Color output for build and debug windows - https://mike-ward.net/vscoloroutput

Xamarin   16.4.000.305 (d16-4@a9ec5d9)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   16.4.0.464 (remotes/origin/d16-4@4abf337c3)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   16.4.25 (579ee62)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   10.1.0.30 (d16-4/5e2fd06)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: e1ef774
    Java.Interop: xamarin/java.interop/d16-4@c4e569f
    ProGuard: xamarin/proguard/master@905836d
    SQLite: xamarin/sqlite/3.28.0@46204c4
    Xamarin.Android Tools: xamarin/xamarin-android-tools/master@9f4ed4b


Xamarin.iOS and Xamarin.Mac SDK   13.8.2.2 (44c08f2)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

bddckr avatar Dec 05 '19 10:12 bddckr

Still happening in iOS using Xamarin.Essentials version 1.3.1 /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2126,5): warning MSB3277: Found conflicts between different versions of "System.Numerics" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. /Library/Frameworks/Mono.framework/Versions/6.4.0/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2126,5): warning MSB3277: Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed. 2 Warning(s) 0 Error(s)

Shaggy13spe avatar Dec 28 '19 15:12 Shaggy13spe

This will be resolved in 1.4.0

jamesmontemagno avatar Dec 29 '19 20:12 jamesmontemagno

Appears to be still happening in Xamarin.Essentials version 1.5.1. I have also made sure all packages on all projects have been updated (core, Droid and iOS).

"warning MSB3277: Found conflicts between different versions of "System.Numerics.Vectors" that could not be resolved."

GeorgeLeithead avatar Mar 25 '20 16:03 GeorgeLeithead

I have the same problem, when I add the System.Text.Json library to manage json instead of newtonsoft. https://www.nuget.org/packages/System.Text.Json use System.Numerics.Vectors (>= 4.5.0)

Warning Conflicts between different versions of "System.Numerics.Vectors" were found and could not be resolved. These reference conflicts are recorded in the generation log when the verbosity of the log is set to Detailed. MyApp.Android

auriou avatar Mar 30 '20 19:03 auriou

I believe that auriou has clarified it further. I too use System.Text.Json instead of NewtonSoft.

GeorgeLeithead avatar Mar 31 '20 14:03 GeorgeLeithead

I am not actually sure if there is anything I can do about this warning actually.

iOS/Android all have a DLL that must be referenced. So when you install System.Text.Json which has a dependency on System.Numeric.Vectors it gives this warning. We can't remove the DLL references as it would fail to compile.

This will probably have to go into the runtime teams. I will have to ask @jonathanpeppers and @chamons perhaps....

jamesmontemagno avatar Mar 31 '20 21:03 jamesmontemagno

It seems that Json.Text.Json does not work on xamarin.ios dotnet/runtime#31326

It is a shame to share its Models (into separate lib netstandard) between its client application and the webapi and especially for the properties of attributes and libs references

Newtonsoft: [JsonProperty ("id")]

System.text.json [JsonPropertyName ("id")]

auriou avatar Apr 01 '20 12:04 auriou

That is interesting. Yeah I think until version 5.0 you should continue to use Newtonsoft.Json.

jamesmontemagno avatar Apr 01 '20 21:04 jamesmontemagno

I believe you will also see this without that NuGet though as we reference it in the .NET Standard Library. It is a bit unfortunate, but only a warning and doesn't cause any actual runtime issues.

jamesmontemagno avatar Apr 01 '20 21:04 jamesmontemagno

for the bug described here https://github.com/dotnet/runtime/issues/31326 , do you confirm that System.Tet.Json still does not work on Xamarin.Ios?

auriou avatar Apr 02 '20 08:04 auriou

I am seeing this issue as well - a relatively blank project in terms of added code. I am not using System.Text.Json package/nuget anywhere. I tried uninstalling the Newtonsoft.Json nuget and still get these warnings. I have read through all the comments/linked comments but still unclear on what the fix for this is. Please advise?

image

I did find this in the ios.csproj file, but i am not sure what package would have added the system.numerics. Is it just safe to delete?

  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />
    <Reference Include="Xamarin.iOS" />
    <Reference Include="System.Numerics" />
    <Reference Include="System.Numerics.Vectors" />
  </ItemGroup>

rezamohamed avatar Apr 08 '20 16:04 rezamohamed

Guys, same issue .... How to fix it? My Project is in suspended mode, can't continue working :(

igormancos avatar Apr 08 '20 16:04 igormancos

So, at this time, they are just warnings that can be ignored and have no impact on your project at all.

We are working with the team to see what we can do, but as of right now they can be ignored. Again, it is a warning and has 0 impact on functionality.

jamesmontemagno avatar Apr 08 '20 20:04 jamesmontemagno

@jamesmontemagno I went ahead and edited these two lines out of the ios and android csproj and my projects seems to work fine. Does it break anything if I just keep them deleted?

<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors" />

rezamohamed avatar Apr 08 '20 20:04 rezamohamed

That should be alright, I am pretty sure... I haven't tested it though @rezamohamed. The main nuget will still be brought in

jamesmontemagno avatar Apr 08 '20 20:04 jamesmontemagno

Remove the package / library "System.Numerics.Vectors" Find the package in the nuget manager "System.Numerics.Vectors"

Boom then fixet :)

TRUSTVIEWIO avatar Apr 13 '20 06:04 TRUSTVIEWIO

Remove the package / library "System.Numerics.Vectors" Find the package in the nuget manager "System.Numerics.Vectors"

Boom then fixet :)

That worked for me. Thank you!

jmoralesv avatar Apr 17 '20 21:04 jmoralesv

I believe you will also see this without that NuGet though as we reference it in the .NET Standard Library. It is a bit unfortunate, but only a warning and doesn't cause any actual runtime issues.

Famous last words. It doesn't instill confidence if that is how the Xamarin team thinks of warnings.

Tommigun1980 avatar May 06 '20 16:05 Tommigun1980

So, I think I may have a working nuget here.

https://dev.azure.com/xamarin/public/_build/results?buildId=18036&view=artifacts&type=publishedArtifacts

After this you can remove the 2 references from your app System.Numerics and System.Numerics.Vectors.

This has a dependency on the System.Numerics.Vectors NuGet package and just an internal reference to System.Numerics and that seems to work well.

This is similar to what I recommended as the work around.

jamesmontemagno avatar May 06 '20 18:05 jamesmontemagno

I see it is almost a year old issue. It still exists. In my case I don't even reference System.Numerics.Vectors anywhere in the solution. I have no idea how to fix it. I tried to reference it in some projects hoping it would resolve it but no. Here is the details for the issue in my case

21> There was a conflict between "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:296) 21> "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not. (TaskId:296) 21> References which depend on "System.Numerics.Vectors, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll]. (TaskId:296) 21> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll (TaskId:296) 21> Project file item includes which caused reference "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Numerics.Vectors.dll". (TaskId:296) 21> System.Numerics.Vectors (TaskId:296) 21> References which depend on "System.Numerics.Vectors, Version=4.1.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" []. (TaskId:296) 21> C:\Users\Alex.nuget\packages\system.text.json\4.7.2\lib\netstandard2.0\System.Text.Json.dll (TaskId:296) 21> Project file item includes which caused reference "C:\Users\Alex.nuget\packages\system.text.json\4.7.2\lib\netstandard2.0\System.Text.Json.dll". (TaskId:296) 21> C:\Users\Alex.nuget\packages\system.text.json\4.7.2\lib\netstandard2.0\System.Text.Json.dll (TaskId:296) 21> C:\Users\Alex.nuget\packages\microsoft.extensions.dependencymodel\3.1.4\lib\netstandard2.0\Microsoft.Extensions.DependencyModel.dll (TaskId:296) 21> C:\Users\Alex.nuget\packages\microsoft.entityframeworkcore.sqlite.core\3.1.4\lib\netstandard2.0\Microsoft.EntityFrameworkCore.Sqlite.dll (TaskId:296) 21> C:\Misc\Project\Main\Application\MainApp\MainApp.Mobile\MainApp.Mobile\bin\Debug\netstandard2.1\MainApp.Mobile.dll (TaskId:296)

alex4998 avatar Aug 19 '20 15:08 alex4998

I believe that 16.7 has made significant progress on this as I no longer see it. https://developercommunity.visualstudio.com/content/problem/788505/xamarin-found-conflicts-between-different-versions.html

jamesmontemagno avatar Aug 25 '20 23:08 jamesmontemagno