Xamarin.Forms version - xamarin.forms

When I create a new Xamarin.Forms project within Visual Studio it uses an old version of the Xamarin.Forms DLL (v2.0.0.6482). In nuget theres an update available to v2.3.0.107.
Why is an old version being used on project creation?
Im on the latest Visual Studio 2015 update and Xamarin version.
Thanks in advance

This is expected since the Forms templates that ship with Xamarin for Visual Studio are not updated as frequently as the package itself. You can go ahead and update the packages to the latest version available on NuGet. Just make sure to update the Forms package in all the projects to the same version.
Note though, only update the Forms package inside the Android project and not the Android Support packages. Forms will also update those to the correct versions needed in order to avoid compatibility issues.

Ok, sounds like it is an issue for a few people.
I have gotten it working with the help of a friend!
It's working fine for me now; I followed the steps below:
Start a new Xamarin.Forms portable project
Uninstall all Xamarin nugets, clear the packages folder (others will be downloaded)
Close VS 2015
Clear the C:\Users_[Username]_\AppData\Local\Xamarin\zips folder, these will be downloaded automatically as needed.
Open the project
Update nugets then install Xamarin.Forms 2.0.0.6490, this should get the relevant version of dependencies for the android project (ie Xamarin.Android.Support.x). This will be v23.0.1.3, even though an update exists, as MatPag stated, it is not yet compatible.
Build.
This will take a long, long time, as the Xamarin\zips folder will be re-populated so a quite hefty file will be downloaded.
Might complain again, clean, save then reopen.
This is will definitely work fine

Related

Missing NETStandard.Library when create Xamarin.Forms project

When I create a new Xamarin.Forms project I got the yellow triangle telling me that I am missing some packages.
Here is what I did:
I reinstalled Visual studio 2017 (I am using version 15.8.9).
If I re-open the project, it's just gone. There is no SDK under the Dependencies anymore.
I used Nuget Package Manage console to try to install the missing library, but nothing happened.
So I would like to hear you guy's opinions. Thank you.
So I figured out the solution. I updated my windows 10 to the newest version and the problem solved!
Came across this issue.
Created a new xamarin forms project using netstandard and got broken references.
Updating all packages in nuget solved the issue.
First build after updating package can take a little bit if xamarin decides that it needs to update its packages.

.NET Framework Dependency appxmanifest

I am in process of prepping my Windows Desktop app for upload to the MS Store. I have a (fully functional) MSI installer for my app and attempted to use the Desktop App Converter (DAC) but experienced an error and have not gotten past it yet. So I decided to give manual package (appx) creation a try and it went well since I was able to install my app using the package I created. But I have a question about how to handle my .NET Framework dependency in the package. My MSI Installer has the '.NET Framework version 4.7.1' as a prerequisite so that it gets downloaded and installed (from MS, if not already installed). My question is how to handle the prerequisite in my package. I'm assuming it would go in the AppxManifest.xml under Dependencies where I currently have (note I removed the brackets so my code would display here)...
Dependencies
TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14316.0" MaxVersionTested="10.0.16299.309" /
/Dependencies
...but I am unsure of the syntax to add .NET Framework 4.7.1 so that it gets properly installed (if not already there) on target systems for my app.
Thanks!
If the app has 4.7.1 as a prerequisite, they will need to set their minversion to 16299 (Fall Creators Update).
In general, you cannot redist .NET with your app package, as it comes with the OS. But if you require a specific version, you need to make sure the minversion matches the update of Win10 that includes that specific version. You could use this table to look it up: .NET Framework Versions and Dependencies.

Xamarin.iOS project: CS1703: Multiple assemblies with equivalent identity have been imported

I've got a cross platform (iOS and Android) Xamarin solution using .NET Standard 2.0. The solution is being built by Visual Studio 2017 (I've tried both the current and preview versions). The Forms and Android projects build fine. However, the iOS fails to build, with the following error:
1>CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\newuser.nuget\packages\system.reflection.emit\4.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove one of the duplicate references.
I've tried many work arounds as described here:
oren.codes
www.hanselman.com
github.com/NuGet
Unfortunately none of these suggestions work. I have also tried to add the System.Reflection.Emit nuget package directly to the Forms and/or to the iOS projects directly. This doesn't work either. Note that originally, the The System.Reflection.Emit package wasn't referenced directly by anything in the solution. It is being pulled in by the following nuget packages which are being explicitly referenced:
Acr.DeviceInfo (5.0.5)
akavache (6.0.0-alpha0038)
AutoMapper (6.2.2)
Microsoft.Identity.Client (1.1.1-preview0040)
Newtonsoft.Json (10.0.3)
Finally, I have tried the update-package -reinstall command in the package console to reinstall all packages for the iOS project. This doesn't work either.
-- update
Just to make this clear, neither the Xamarin Forms or the Xamarin iOS project directly reference System.Reflection.Emit. That package is being pulled in as a dependency of other nuget packages, just from packages that are installed into the Xamarin Forms project. I have confirmed all of the dependencies that are referenced by Nuget, are using the same version. See these screenshots:
It seems to me that the problem (as the error says) is that there is an old version of System.Reflection.Emit that was installed by Visual Studio. However, I can't find a way of ignoring it and using the version of System.Reflection.Emit instead. As I've said above, I have tried to use a project.json file in the Xamarin.iOS project, and manually ignoring, but this doesn't work.
Does anyone else have any ideas?
As an aside, I notice that this bug is still open for Xamarin.
Xamarin Bugs
Managed to get this resolved thanks to an answer by #DirkWilhem on Xamarin Forums site.
Basically, add this to your Xamarin iOS project's .csproj file, with the other PackageReference nodes:
<PackageReference Include="System.Reflection.Emit">
<Version>4.3.0</Version>
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
Of course you need to make sure the nuget package has been added to the iOS package first.
Xamarin Forums discussion
After spending hours trying to resolve this myself I may have found a solution. Although it does feel wrong, it has got me past the issue.
Moving/Deleting the Xamarin.iOS version of System.Reflection.Emit.dll has solved the build problem for me and enabled me to deploy and run my app on a device. I don’t know what side effects it might have so will need more testing but I thought I’d share what’s worked for me so you can test it as well.
I was running on macOS Visual Studio 2017 but switched over to Windows to try and fix and first fixed on there then tried same approach on macOS and it worked as well.
On windows, go into the following directory and move the System.Reflection.Emit.dll somewhere else (you could just straight up delete it but I wanted to keep a copy I case this has some undesired effects down the track):
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades
On mac the following directory has it:
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Facades
Like I say, it feels wrong but for now it’s got me past an issue that’s had me blocked for a couple of days so willing to just move on and hope there’s no side effects. I’d be interested to know your experience with it and if you come across anything else for the future too.
I’ll post this same comment on the Xamarin forums post (https://forums.xamarin.com/discussion/120814/xamarin-ios-project-cs1703-multiple-assemblies-with-equivalent-identity-have-been-imported) as well for future reference.
I had the same issue around a custom Nuget packages that we created and consumed in a separate project. We got around this issue by removing the automatic Nuget building checkbox in the "options" for the project. This does add the extra step of "Create Nuget Package" but one we pushed it to our Nuget repo and consumed it in our project, the errors vanished.
The problem showed up when we updated the sub-projects from PCLs to .netstandards (2.0).

Xamarin.Forms cannot update Xamarin.Forms Package from version 2.3.4.270 to 2.4.0.282

I'm trying to update a project to the newest version of Xamarin Forms and I'm getting an error. The error is the following
Unable to resolve dependencies. 'Xamarin.Android.Support.Design 25.4.0.2' is not compatible with 'Xamarin.Forms 2.4.0.282 constraint: Xamarin.Android.Support.Design (= 23.3.0)'.
Although the error message is obvious, it's strange that the new Xamarin.Forms package needs an older version of Xamarin.Android.Support.Design.
So, I created a new project and I saw that the versions in the new project are:
Xamarin.Forms 2.4.0.282 and Xamarin.Android.Support.Design 25.4.0.2 (!)
That's odd. The new project contains the version 25.4.0.2 Xamarin.Android.Support.Design. The old project rejects the update because it contains that version of Xamarin.Android.Support.Design. Doesn't make much sense.
So, the question is Why, am I getting this error and why I cannot update to the new version of Xamarin.Forms?
Try update your android support libraries first and then update to the latest xamarin forms 2.4.0
You're getting the error because Xamarin does not use latest versions of those android support libraries. You can see that when you install Xamarin.Forms package (Nuget-Manager: update only Xamarin.Forms), if it depends on newer versions of android support packages it will automatically update them.
So basically as long as Xamarin.Forms does not use latest android packages, they will always show 'update available' but when you update them, they're not compatible with Xamarin.Forms anymore.
Edit:
Sometimes it seems deleting packages and bin/obj folders is not enough.
If found this link with instructions for deleting nuget cache.
Fixing Xamarin.Android build errors

Xamarin with Entity Framework Core: Error: unauthorized access to "/system/lib/libsqlite.so" on Android 7

Im trying to create a Xamarin Forms App using the new Entity Framework Core. The app targets android 6.0 but my Emulator is running Android 7.0. I installed the following related Nuget packages on the android project:
Microsoft.EntityFrameworkCore --> 1.1.1
Microsoft.EntityFrameworkCore.Sqlite --> 1.1.1
When accessing my DbContext on Android a message will pop up telling: Detected problems with native libraries unauthorized access to "/system/lib/libsqlite.so".
This Xamarin forums thread suggests, that it's due to the native SqLite binaries are no longer supported (on Android 7?) and the common fix seems to be to switch to the SqLite.Net PCL.
However as Microsoft.EntityFrameworkCore.Sqlite depends on Microsoft.Data.Sqlite which in turn depends on the native SqLite package I cannot just replace this (or can I?)
Strangely enough, despite of the error message suggesting otherwise, the data access seems to work. At least migrations run and repeated writes to the database will create new Ids.
Of course I could just scrap EF Core but I guess a lot of people are looking into using it for Xamarin in the future. So it would be nice if anyone would find/know a fix.
I had the same problem. I have fixed this using the following libs: sqlite-net-pcl (version 1.2.0), SQLitePCLRaw.bundle_green, SQLitePCLRaw.core, SQLitePCLRaw.lib.e_sqlite3.android, SQLitePCLRaw.provider.e_sqlite3.android.
Matheus Souza had the right idea there. However installing SQLitePCL is only part of the answer. Here is how I eventually solved this:
DISCLAIMER: This is a kind of "You can do it but it isn't pretty"-solution. If you have the time, it's probably best to wait for the official Microsoft.EntityFrameworkCore.Sqlite 1.2.0 release.
This issue brought me on the right track. The new (unreleased) version of EntityFrameworkCore no longer uses the native sqlite binaries, but sqlite-net-pcl. This is the steps I followed to install it:
Add the aspnetcore-dev branch to your nuget feeds. Nuget 3: https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json
Check "Show preview versions" in Nuget and update (or reinstall) all EntityFrameworkCore packages to "1.2.0 - preview"
(Make sure your x64 is checked in your android projects advanced build options, if the app instantly crashes on deploy. This might be unreleated)

Resources