Switching Your Xamarin Project to Standard Class Projects

As Xamarin Developers will always have two alternatives when choosing what to select for shared code:

Shared Projects – with conditional compilation and source code sharing over platforms.

Portable Class Library – additional project in solution that’s referenced by stage particular projects.

There are parts of contrasts between using a Standard Class/Portable Class Library (PCL) and Shared projects in a Xamarin solution. However, the most obvious one shows up when you open any XAML file in a Shared project: In a Standard Class library you’ll get IntelliSense support; in a Shared Project you won’t get any IntelliSense Support and virtually each element in your XAML file will be flagged as an error.

Unless you’ve got a compelling reason to go with a Shared project (for example: your version of Visual Studio doesn’t support Standard Lesson Library projects), you’ll need to use PCL or a Standard Class Library project … and a Standard Class Library project is your best choice going forward. In fact, if your version of Visual Studio doesn’t support Standard Class Library Projects and you want to work with Xamarin, it can be time to upgrade to a more up to date version of Visual Studio.

However, now we have a new alternative which is .NET Standard Project. According to Microsoft, .NET Standard may be a specification of .NET APIs that can be used and are available on all .NET implementations (including Xamarin platform projects like iOS, Android or UWP). It is very comparative to PCL, but it’s simpler to use and has more classes accessible from BCL (Base Course Library).

In case you’re not sure which kind of project your Solution is as of now using, to begin with look at the icon beside your common project in Solution Explorer: In case it’s two overlapping methods, you have a Shared project, if you’ve got a basic box with “C#” inside of it at that point you have got a Standard class Library or a PCL project. To recognize between a PCL and a Standard Class Library, open the project’s properties and see if you’ve got a Library tab on the cleared out. Incase if you are, doing you’ve got a PCL extend.

So, let’s see what are the advantages of using .NET Standard?

.NET Standard defines a universal set of BCL. It means you can be sure that your .NET Standard library can be utilized anyplace where .NET Standard is in use (which is getting to be a very common thing).

NET Standard could be a set of APIs that are carefully selected and known to be interchangeable, whereas PCLs are just a simple intersections of different .NET Platforms.

.NET Standard is versioned (from 1.0 up to 2.0 and more in future) and is in reverse compatible.

PCL Profiles are just representations of different platforms and .NET Standard is free of any of them.

Xamarin can compatible with .NET Standard?

It all depends. .NET Standard is compatible with many PCL Profiles but as it were in one way – it means that you just can reference a few PCL DLLs in .NET Standard project but not the opposite . At last – in case you’re on Apple side you cannot utilize .NET Standard libraries in Xamarin Studio, you must move to Visual Studio for Mac. On the other side, you should consider doing that as soon as possible – Xamarin Studio isn’t supported any longer.

Leave a Comment