Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame
Welcome to the final installment of my Xamarin article series. I think you'll agree that we have covered a lot during the past few months, and I hope that this series has helped you in some way. The last thing I'd like to talk about is PCLs (Portable Class Libraries), and today you will learn about them and what they do.
Portable Class Libraries
A Portable Class Library (PCL) can be supported on multiple platforms, such as:
- Windows Phone
- Windows Store
- Xbox 360
Why is this important?
Building cross-platform applications used to be quite difficult. Now, with the use of PCLs, we can share code across various platform-specific projects. Remember, different platforms use different sub-sets of the .NET Base Class Library (BCL), meaning that they are in fact built to a different .NET Core Library Profile. That meant that each platform could only use class libraries that were targeted to that same profile.
Upon creating a Portable Class Library, we can choose a combination of platforms we want our code to run on. The compatibility choices you make upon creating a PCL are translated into a Profile that describes which platforms the library supports.
Creating a PCL
To create a new library that can be shared on various platforms, use the following steps:
- Start Visual Studio.
- Click File.
- Select New, then Project.
- Select the Class Library (Legacy Portable), as shown in Figure 1.
Figure 1: Class Library
- Click OK.
- The screen shown in Figure 2 will appear.
Figure 2: Profile
- Select All of the checkboxes; then, click OK.
- Notice the project name in the Solution Explorer: It includes the word Portable.
This project we have created now will be able to run on all the platforms we selected earlier. This is a Class Library, so it doesn't have a User Interface; we need to set a reference to this project wherever we want to use it.
Add a Reference by Selecting, Project, Add Reference, and select the project (see Figure 3).
Figure 3: Reference Manager
This concludes my Xamarin series. I hope that you have enjoyed it and benefited from it.