Xamarin Forms "Todo DocumentDB" sample - Higher version than referenced assembly System.Collections.Specialized error - xamarin

I'm using Visual Studio 2013 and can't seem to fix the following build error that I get when I go to https://developer.xamarin.com/samples/xamarin-forms/WebServices/TodoDocumentDB/ and download the sample code and attempt to run it:
Error 2 Assembly 'Microsoft.Azure.DocumentDB.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' uses
'System.Collections.Specialized, Version=4.0.1.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced
assembly 'System.Collections.Specialized, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' c:\Users\Elijah
Lofgren\Downloads\T1mobio\TodoDocumentDB\packages\Microsoft.Azure.DocumentDB.Cr
e.1.0.0\lib\netstandard1.6\Microsoft.Azure.DocumentDB.Core.dll
TodoDocumentDB.Droid
I've tried updating all the nuget packages but that hasn't worked.
I can't seem to find anyone else with this error.
Thanks!

It looks like this code is not compatible with Visual Studio 2013 on PC.
On PC, you need to use Visual Studio 2015 (or newer).
On Mac, you can use any version of Visual Studio for Mac.

Related

"XAMLTaskFactory" could not be loaded from Assembly

I've been trying to run x86 assembly code on my machine for schoolwork. Sadly I've been getting this error when trying to build the project files and I can't figure out what it's about and how to fix it:
Error MSB4175 The task factory "XamlTaskFactory" could not be loaded from the assembly "Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". The system cannot find the path specified hi C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\masm.targets 70
Has anyone had the same problem? I've tried making new projects, running as administrator, done a clean install of Visual Studio and all the packages, even factory reset my laptop.

VS Community - Cannot run a simple console application: Could not load file or assembly ‘System.Reflection.Metadata'

I’ve installed Microsoft Visual Studio Community 2019 Version 16.9.4 and tried to create a simple console application to print “Hello World”.
If I run the app with dotnet run from the Windows Command Prompt, it will run successfully, but opening the project in VS and trying to start the console app is causing the following error:
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly ‘System.Reflection.Metadata, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)
I’ve already tried to start the console app as x86 and x64, but that did not help.
Another attempt was to uninstall VS 2019 and install VS 2017 Community. Have the same exception when I build the console app.
Unhandled Exception: System.BadImageFormatException: Could not load file or assembly 'System.Reflection.Metadata, Version=1.4.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The file or directory is corrupted and unreadable. (Exception from HRESULT: 0x80070570)
Could someone please help me with this?

"Can not resolve reference: `System.Memory`" or "Could not find `System.Memory`" after update to Visual Studio 2017 version 15.8 Preview

In case it might help anyone else, I'll ask and answer this little question about an issue that can appear in Xamarin.Android and Xamarin.iOS projects after an update from Visual Studio 2017 version 15.7 to version 15.8 Preview.
Example steps to demonstrate the issue
Create a new blank Xamarin.Android or Xamarin.iOS project.
Add the Microsoft.AspNetCore.SignalR.Client.Core version 1.0.0 NuGet package to the project.
Use a type from the NuGet package in the project. For example, add the following line to any existing method:
var connection = new Microsoft.AspNetCore.SignalR.Client.HubConnectionBuilder().Build();
For Xamarin.Android, attempt to build the project in the Debug configuration. For Xamarin.iOS, build and run the app in the Debug configuration on iPhone simulator.
Results with Visual Studio 2017 version 15.7
Both the Xamarin.Android app and the Xamarin.iOS app build and run without error.
Results with Visual Studio 2017 version 15.8 Preview 4
For Xamarin.Android, the build fails:
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.Connections.Abstractions`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.Connections.Abstractions`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.SignalR.Client.Core`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.SignalR.Client.Core`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.SignalR.Common`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.SignalR.Common`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.AspNetCore.SignalR.Protocols.Json`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.AspNetCore.SignalR.Protocols.Json`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `Microsoft.Extensions.Primitives`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `Microsoft.Extensions.Primitives`.
Xamarin.Android.Common.targets(1831,2): error XA2002: Can not resolve reference: `System.Memory`, referenced by `System.IO.Pipelines`. Please add a NuGet package or assembly reference for `System.Memory`, or remove the reference to `System.IO.Pipelines`.
For Xamarin.iOS, the app launches successfully on the simulator, but the debug output shows that the app fails to find System.Memory when it's running:
Could not find `System.Memory` referenced by assembly `System.IO.Pipelines, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.SignalR.Client.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.SignalR.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.Extensions.Primitives, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.Connections.Abstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
Could not find `System.Memory` referenced by assembly `Microsoft.AspNetCore.SignalR.Protocols.Json, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60`.
How do I resolve these errors? As a follow-up, why did these errors appear after I updated Visual Studio?
I use VS Entreprise 2017 Version 15.9.1
To solve the problem I face ( Can not resolve reference: System.Buffers, referenced by System.Memory. Please add a NuGet package or assembly reference for System.Buffers, or remove the reference to System.Memory.),
I just install System.Buffers package by this command:
Install-Package System.Buffers -Version 4.5.0
https://www.nuget.org/packages/System.Buffers/
How do I resolve these errors?
To resolve these errors, update the Microsoft.AspNetCore.SignalR.Client.Core NuGet package to version 1.0.1 or higher in all the projects that use it. For example:
Go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution > Updates.
Update Microsoft.AspNetCore.SignalR.Client.Core to version 1.0.1 or higher.
In Microsoft.AspNetCore.SignalR.Client.Core version 1.0.1, the System.Memory NuGet dependency is now (>= 4.5.1) rather than (>= 4.5.0). And because System.Memory version 4.5.1 no longer includes placeholder files for Xamarin project types, Xamarin projects will now use the .NET Standard 2.0 assembly directly from the NuGet package. This solves the errors because the Xamarin projects can now successfully locate the System.Memory reference.
As a follow-up, why did these errors appear after I updated Visual Studio?
The errors appeared because the Xamarin SDK versions in Visual Studio 2017 version 15.7 and version 15.8 have a tricky compatibility relationship with the System.Memory NuGet package versions. In Visual Studio 2017 version 15.7, Xamarin.Android and Xamarin.iOS use their own built-in implementations of the types from that NuGet package, so they don't need to reference the assembly from the NuGet package. The System.Memory NuGet package version 4.5.0 accordingly includes placeholder files for Xamarin project types to prevent conflicts.
But the built-in implementations in the current Xamarin SDK releases do not yet cover the full surface area of the NuGet package. So for Visual Studio 2017 version 15.8, the Mono team temporarily hid those built-in implementations (by switching them to internal and removing the System.Memory facade assembly). This means that Xamarin projects now depend on the implementations from the NuGet package instead. And the System.Memory NuGet package version 4.5.1 accordingly does not include placeholder files for Xamarin project types.
One more thing to keep in mind is that the built-in implementations in the Xamarin SDKs will cover the full surface area of the NuGet package in a future release. The built-in implementations will then be un-hidden and the placeholder files will be added back to the NuGet package. Users will need to update their NuGet packages once more when that happens. That next change will be coming in Visual Studio 2017 version 15.9 or later.

Could not load file or assembly 'System.Web.RegularExpressions, Version=4.0.0.0

Last night I upgraded my Visual Studio 2017 to the latest version 15.7.0. Since then all my projects are not running any more.
The error I am getting:
Could not load file or assembly 'System.Web.RegularExpressions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I tried adding manually a referece to the DLL, I am still getting the error
I fixed the issue by 1) updating Visual Studio from 15.7.0 to 15.7.1 2) repairing the installation

Error loading Visual Studios 2012

Everytime i try to open Visual Studios 2012, an error message displays
" Could not load file or assembly 'PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e25' or one of its dependencies. The system cannot find the file specified."
Any idea what is wrong? How to fix this?
Try to Uninstall the Visual Studio that you have and download it from http://www.microsoft.com/visualstudio/esn/2013-preview. It works for me perfectly.

Resources