Microsoft’s flagship product .NET is a programming platform that gives users opportunities to undertake a wide range of tasks, from the creation of simple console applications to the end-to-end development of highly scalable web, desktop, mobile apps, IoT solutions, and more.
In this article, we’ll discuss in detail the tools and methods .NET provides for developing mobile applications. Let’s take a look.
What Is .NET?
First let’s get a general idea of what .NET is. The traditional definition goes something like this: “.NET is an open-source and free framework by Microsoft used to develop various types of applications for various platforms and being an integral part of Windows OS.”
Diving a bit deeper, we understand that .NET is a huge ecosystem of software products (languages, developer tools, libraries, runtime environments, etc.) for cross-platform development.
The following are the key components.
- .NET Framework — the initial product released in 2002, which aimed to develop applications and services on Windows only.
- .NET Core — the platform-agnostic framework appeared in 2016 and enabled cross-platform development.
- Xamarin — the framework for developing cross-platform mobile applications. It was created by the Mono project and then purchased by Microsoft and integrated into .NET.
- MAUI (Multiplatform App UI) — the next evolutionary step of Xamarin, which will support Android, iOS, macOS and Windows.
- C#, F#, Visual Basic — most popular programming languages used in .NET.
- Visual Studio — the basic development environment for .NET projects. Options include Visual Studio Code and Visual Studio for Mac.
- Command line interface (CLI) — a toolchain for creating, running and publishing cross-platform applications.
- .NET Standard — a common set of APIs, ensuring unification within the ecosystem. Starting with .NET 5, this approach to unification has become obsolete.
- Common Language Runtime (CLR) — the environment used to manage the execution of software components written in various languages.
- .NET 5 — a step forward to a single platform, taking the best of .NET Framework and .NET Core and enabling the development of applications for all devices from a single place. Released in 2020.
- .NET 6 — a unified development platform allowing you to create desktop, web, mobile, cloud, IoT, gaming and AI applications. Released in 2021.
Note! If there were still separate products in .NET 5 (.NET Framework, .NET Core), they have now merged under one name — .NET 6. So, you can launch this single version and create any types of solutions. All the previous products now have common libraries, APIs and infrastructure components.
As you can see, the .NET ecosystem is highly diverse, given that we’ve mentioned only some major components. The list can be complemented by numerous libraries, runtimes and other tools.
What Is the Use of the .NET Framework?
According to Statista, .NET Framework was the most used framework among developers worldwide in 2021, with .NET Core/.NET 5 in the top three as well. This fact proves that the platform has a broad scope of application, including:
- desktop applications
- web applications
- mobile applications
- enterprise systems (CMS, ERP)
- IoT solutions
The following hints suggest when the various .NET products should be used.
- Use .NET Framework if you need a desktop or server-based application running on Windows OS only.
- Use .NET Core if you need a cross-platform web app (should run on Windows, Linux, macOS) — if you need a high-performance and scalable solution based on the microservices architecture and Docker containers.
- Use Xamarin if you need cross-platform, hybrid or native applications for mobile operating systems (iOS, Android).
Frontend Mobile Development in .NET
The frontend of mobile applications is the part that users see and interact with. Frontend developers and web designers work together to implement the logic and its visual representation. In .NET, there are several tools for frontend development.
Xamarin is the most popular open-source frontend framework in the .NET family. It enables cross-platform development — i.e., the project has several target platforms at once (Android, iOS). With Xamarin, you can create mobile applications in two different ways.
First development option — a separate UI for each platform
Using Xamarin Native, you can develop Android and iOS apps independently. This means that you will have to write unique code for each solution with the help of native features (XML files, storyboards) provided by Xamarin.iOS and Xamarin.Android libraries. At the same time, the backend of such solutions can be shared.
As an example, I want to show you the Android layout file for one of our company’s internal applications:
And this is the resulting screen:
The main advantage of this approach is that, though coding for different platforms, you use one language, C# (instead of Swift, Java, and others). You can also incorporate third-party SDKs specific for both platforms due to bindings that Xamarin provides. This is very convenient as you get everything in one place.
Second development option — a single UI for all platforms
Using Xamarin.Forms, you can write a sharable UI code for all platforms. Of course, you will need some minor code adjustments for each target platform, but this is much quicker than having to develop separate solutions.
Take a look at this example of a UI layout based on Xamarin.Forms:
The output of this code is exactly the same screen as in the screenshot above.
Moreover, Xamarin supports other platforms such as Windows, Mac, Linux (GTK) and Tizen, so you can develop an application that will run on a wider range of mobile devices. Thus, Xamarin is rightly considered to be a comprehensive mobile app platform that frontend developers can leverage for cross-platform projects.
MonoGame and Unity
The two other options for mobile frontend development in .NET are Unity and MonoGame. While Xamarin is used for general-purpose mobile solutions, these frameworks focus on the development of mobile gaming applications for iOS and Android (but they also support other platforms).
MonoGame is a free framework used to create games for mobile devices, consoles and desktop computers. This is the successor to the Microsoft XNA framework that was used to develop games for Windows a decade ago. The code in MonoGame is written in C# and targets the iOS and Android mobile platforms, as well as other platforms that run games, including Windows, macOS, Linux, PS4, PS Vita, Xbox One and Nintendo Switch.
MonoGame is a less powerful tool than Unity. However, it provides a range of features that enable 2D and 3D rendering, the management of sounds, and images and states in the game.
Unity is a fully featured platform offering real-time 3D experiences not only for game development but also for creating films, automotive solutions, architectural projects and more. With built-in VR/AR capabilities, Unity can be a great tool for any application that requires realistic visualization.
Unity provides a simple-to-use editor where you create objects and then implement their logic with the help of .NET technologies.
Here’s an example of the Unity script:
Platforms supported by Unity include:
- mobile — iOS, Android, tvOS
- desktop — Windows (UWP), Mac, Linux
- web — WebGL
- console — PlayStation, Xbox, Nintendo Switch, Stadia.
As you can see, gaming engines like Unity provide advanced capabilities for mobile development, which is highly valued by modern users. However, when considering the tool for frontend mobile development, keep in mind all the technical requirements. Frameworks like Unity with VR/AR/3D capabilities can cause certain difficulties to mobile solutions because mobile devices have limited resources (battery life, processing power, etc.) and might not be able to perform tasks as quickly as required. At the same time, script writing based on Xamarin is lightweight.
How to Build and Run Mobile Applications?
The process of building and running mobile apps differs from that for desktop or web apps, because with mobile, you focus on a wide range of devices instead of a general-purpose PC. Hence, you can’t use a “traditional” computer; you need either a physical mobile device or an emulator that imitates the performance of such devices.
Build and run
With applications for Android, it’s simple: you can work on a computer with any operating system, use Visual Studio to select either a virtual device (emulator) or a connected physical device, and run your application.
With iOS solutions, you can work only on a computer running macOS. The good news is that Xamarin provides the Remoted iOS Simulator for Windows, so you can test your iOS apps in their target simulator and display it on your Windows machine.
Backend Mobile Development in .NET
The backend part of a mobile solution “lives” at the server side and out of the user’s sight. Of course, there are simple mobile applications such as a calculator or voice recorder that don’t need a backend, since they don’t have to store and process data. But to create large solutions with complicated business logic, the backend development team has to work hard in order to make the magic happen under the hood.
ASP.NET Core and ASP.NET Web API
It should be noted that backend development for mobile applications is the same as for web apps. Thus, if you need to develop several mobile and web solutions with the same functionality, you can share the backend service, which is super convenient and time- and cost-efficient.
To develop the web service infrastructure for your mobile application, you need to create a REST API serving as a mediator between the mobile frontend and backend. For this purpose, you can use ASP.NET Core, selecting a web API project template in the .NET Core infrastructure. Then, you’ll need to add a database context, apply CRUD methods, configure URL paths, routing, return values, etc.
Visual Studio App Center
In case you need to go beyond the backend development process and integrate it with the system administration, virtualization, security management, continuous integration/continuous deployment (CI/CD) and other practices, you should focus on the DevOps tools.
Visual Studio App Center is a web portal designed to enable DevOps practices in mobile app development. It provides integrated development services for automating the life cycle of applications for iOS, Android, Windows and macOS. Using Visual Studio App Center, you can:
- connect a repository
- build a project in the cloud
- test your application on thousands of devices at once
- distribute apps to beta testers and app stores
- monitor performance in real time
- track crash reports and analytics.
As a result, you can build your application, monitor its performance and stability, and address reported errors from a single cloud-based platform.
Azure Mobile Apps
One more option for building and hosting the backend for .NET-based mobile solutions is Azure Mobile Apps. The technology offers a range of capabilities for cross-platform and native applications:
- On-premises or cloud data storage
- Customer authentication
- Offline data synchronization
- Personalized push notifications
- Built-in autoscale
If you compare Visual Studio App Center and Azure Mobile Apps, both tools are popular among .NET developers. However, the former has a wider range of DevOps services and is more actively developed at the moment. Hence, the choice of the most appropriate tool should be based on the project goals, tech needs and financial capabilities.
Why Consider .NET as an Excellent Option?
.NET has been on the market for so long that it has become a recognized brand. Today, there is an extended ecosystem of software products, libraries and tools that are written specifically for the .NET Framework. This provides incredible flexibility in terms of solutions you can develop with .NET.
We’ve compiled a list of the best reasons why you should consider .NET for mobile development.
- Sharable code — you can create a single codebase for several platforms, which reduces development time and expenses.
- Single technological stack — all the tools you need for mobile app development, including IDE, SDK, testing and analytical tools, are available in one place.
- Security and reliability — Microsoft contributes to the reliable operation of its servers and continuously improves the security features of its products. You can therefore be sure that you’ll produce secure and reliable solutions if you develop them with .NET.
- Support — .NET is an open-source technology with strong corporate support by Microsoft. Its global community brings together millions of developers who contribute to the platform’s further development and who would be glad to help you address any issues that may arise with your project.
As you can see, over the years of its existence, .NET has become the most profitable development environment for a wide range of platforms, including Android, Linux, macOS and iOS.
SaM Solutions is a certified Microsoft partner with the following competencies:
- Gold Application Development
- Gold Collaboration and Content
- Silver DevOps
- Silver Cloud Platform
Our team of experienced and motivated .NET developers have successfully implemented numerous projects and earned the praise of many satisfied customers over the years. We will gladly transform your ideas into efficient mobile (or other) solutions, so don’t hesitate to contact us.
Thank you for such valuable information and practical examples. It’s essential to get insights on software development from experienced specialists. You are doing a good job.
Concerning gaming applications based on .Net, I would say that Unity is the number one tool, while MonoGame has become obsolete. But this is my opinion, I could be wrong.
Not only mobile development, with .NET you can create practically any type of software and adjust it to any business requirements. Thanks for the post and keep on writing.
For me, .NET is the best example of how software development tools should work and what capabilities they should provide to developers. You’ve done a great job covering the major aspects of mobile development with .NET in this blog.
I appreciate the information with practical examples you’ve provided. Indeed, Xamarin is a great tool for creating native user experiences for different mobile platforms.
This is a very helpful article for dotnet developers, for those who start their career in developing mobile applications with .NET. I’d like to encounter more content on the topic like this on the web.
Hi Andrei! Thank you for this comprehensive blog post and especially for the examples of code. The information is very useful for beginners in .net mobile development like me.