Page
1
(This page has no text content)
Page
2
Building Mission-Critical Applications with .NET 10 and C# 14 A Guide to Engineering Modern Cloud-Native .NET Applications with Less Pain Afzaal Ahmad Zeeshan
Page
3
Building Mission-Critical Applications with .NET 10 and C# 14: A Guide to Engineering Modern Cloud-Native .NET Applications with Less Pain ISBN-13 (pbk): 979-8-8688-2346-6 ISBN-13 (electronic): 979-8-8688-2347-3 https://doi.org/10.1007/979-8-8688-2347-3 Copyright © 2026 by Afzaal Ahmad Zeeshan This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Smriti Srivastava Development Editor: Laura Berendson Editorial Assistant: Jessica Vakili Cover designed by eStudioCalamar Cover image designed by Pixabay.com Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub. For more detailed information, please visit https://www.apress.com/gp/services/ source-code. If disposing of this product, please recycle the paper Afzaal Ahmad Zeeshan Almere Buiten, The Netherlands
Page
4
This book would not be possible without the support of my family. So, to my wife Iqra, my elder daughter Aisha, and the new member Deeba.
Page
5
(This page has no text content)
Page
6
(This page has no text content)
Page
7
(This page has no text content)
Page
8
(This page has no text content)
Page
9
(This page has no text content)
Page
10
(This page has no text content)
Page
11
(This page has no text content)
Page
12
(This page has no text content)
Page
13
xiii About the Author Afzaal Ahmad Zeeshan is a Developer Advocate currently living in the Netherlands and likes to use .NET Core and Node.js for normal everyday development. He enjoys Cloud, Mobile, and API development. Afzaal has experience with the Azure platform and likes to build cross-platform libraries/software with .NET Core. He is an Alibaba Cloud MVP and has twice been awarded Microsoft MVP status for his community leadership in software development, four times been awarded CodeProject MVP status for technical writing and mentoring, and four times been awarded C# Corner MVP status in the same field.
Page
14
xv About the Technical Reviewer Sourabh Mishra is an entrepreneur, developer, speaker, author, corporate trainer, and animator. He is a Microsoft guy; he is very passionate about Microsoft technologies and a true .Net Warrior. Sourabh started his career when he was just 15 years old. He’s loved computers from childhood. His programming experience includes C/C++, Asp.Net, C#, Vb.net, WCF, Sqlserver, Entity Framework, MVC, Web API, Azure, Jquery, Highcharts, and Angular. Sourabh has been awarded a Most Valuable Professional (MVP) status. He has the zeal to learn new technologies, sharing his knowledge on several online community forums.
Page
15
xvii Introduction For a developer, a new framework or a library, or a runtime is always an interesting new specie to explore and experiment with. We wear our invisible lab coats and dive into the new libraries as soon as they are released. Most of us even go as far as developing production applications with the release candidates, trusting that the only thing left is ironing and not deprecation of incomplete features. Over the last decade, I’ve grown to learn • Never trust the day-one production readiness of anything. • Games? • New phones? • Frameworks? Only get them on day-one if you’re reviewing them. • Just because a feature is available does not mean you should use it. • I cannot emphasize enough how much I am annoyed by the overuse of null check operator. • Don’t upgrade to the latest version the day it becomes available, and don’t wait until the last day either. • It hurts if you upgrade to a broken version; it hurts more when your system gets hijacked because of a vulnerability beyond the support timeline. The new versions always bring an excitement because they are packed with opinionated frameworks, libraries, and simpler SDKs, or features that you had to write yourself—all bundled in the new framework. It is all fun, until this very new framework that you just integrated with your production project is already reaching its end of life. That is what happens when you use a non-LTS version, or when you attempt to use this version to test something, but before you deprecate or obsolete the new app or feature, you move onto something else.
Page
16
xviii That contributes excessively to the overall tech debt of your business. What I always found fascinating was how you have to update to a new version of the framework every few years. Why can’t we just have something work for at least five or six years? The framework should be responsible for maintaining the internals. But hey, it’s a new major version and I cannot complain that it breaks a few things here and there. This book is for you if you also find learning technologies very interesting, but always take new products, new frameworks, and new runtimes with a grain of salt before adding them to your production environment. The current development experience and developer productivity landscape is changing rapidly, the framework you learned two years ago is no longer the shiny one today, and today a new library is replacing that. Take a look at the JavaScript ecosystem; they have a new library for everything. It would not be cynical to say that it is possible to glue together a handful of libraries and get a working program with less than 20% of your own code. While that does translate to “productivity”—especially when these libraries come from your own enterprise and you are only writing the business logic for your module—it does bring a lot of responsibility on the developers or the team. • How do you contain the impact that each dependency has? • How do you decide to obsolete a dependency? • How do your developers know what is internal vs. external? Do you block all external dependencies by default? Quickly this becomes a cultural question and not a technical one. And most decisions are either enabled or blocked by this thinking activity. You either allow too much, or you block too much. And both ends of the spectrum contribute to engineering challenges, technical debt, cross-team communication problems, and incidents. The way I see things, the question is never “should we allow this framework?”, or “should we migrate to this library?”. Instead, it is always “in which environment can we use this framework?”. That difference in the approach helps engineers understand what the acceptability of the framework is, what is the risk appetite, and what happens if we either like the framework too much or we dislike it too much. This book contains several similar questions and scenarios that you should use to be clear with your peers to clearly explain the objectives and outcomes. Even though I am a .NET engineer, I can get the same outputs using Java, Python, Go, yeah maybe even Perl. When you frame the question as where you would use this language, the answer is easier. And another reason why a question posed at environments is easier to answer is because InTroduCTIon
Page
17
xix environments change frequently. Today, you may have development, staging, beta, and production, and a few quarters later you may have an extra QA, or canary, or I don’t know, but you get the point. Last, but not least, this book is not a cookbook, it is not an Essential .NET-style content either. This is a set of questions, scenarios, answers, and dilemmas to use when you go about developing. The core of the book contains material to help you decide when .NET makes sense and when it does not. .NET 10 brings a lot of improvements and features to make .NET and C# feature-compatible or may I say purpose-compatible with other languages. Each feature also brings a new way of thinking for a .NET program, and how your “Enterprise” solution should be broken down and rewritten. In the end, I expect that by the end you will have more questions, more curiosity, and more urge to open the hood—LINQPad (https://www.linqpad.net/) is amazing at that—and read more about what’s actually happening. And, if you learn something, please teach me as well @afzaalvirgoboy. :) InTroduCTIon
Page
18
3 © Afzaal Ahmad Zeeshan 2026 A. A. Zeeshan, Building Mission-Critical Applications with .NET 10 and C# 14, https://doi.org/10.1007/979-8-8688-2347-3_1 CHAPTER 1 .NET Ecosystem It is unfair to call .NET just a framework anymore; it is an entire ecosystem of platform, frameworks, libraries, communities, products, services, and concepts that enable organizations across the globe to translate their ideas and goals into realities. Oh, and it has been doing that since the early 2000s. For decades, Microsoft .NET has been a go-to standard for enterprise application development for organizations. Since its first introduction, Microsoft .NET has impressed developers with its maturity in software development. It has one of the best development experiences, tooling, documentation, and the community. It is plausible how Microsoft has invested in the framework as a product. For a framework, the audience needs to know how well the framework has been documented, how easily they can get started if they need to pay to use the development framework, and if they stumble upon a problem, how quickly they can find it a resolution, etc. The biggest question is, does the parent company dogfood themselves? Do they use the framework for their own products and services? For Microsoft, that has been the case for years as they helped put the .NET framework on the face of the development landscape. Microsoft has invested in the evangelism roles with thought leaders and community experts to drive the community around the .NET framework for years. Note I am a fan of the .NET framework and have used .NET Core since the early beta days. This book aims to be less opinionated and contain information that you can use to build your enterprise applications using the .NET framework. .NET has evolved from a language for console-based, web-based, and graphical application development choice for Windows applications to a broader clientele. Part of this success is kudos to Microsoft for investing heavily in a framework as a product and to the community of developers and experts who supported their years in the technology. As part of this journey to celebrate the .NET 10 release, this book will take you on a
Page
19
4 journey as a .NET engineer. You will get hands-on experience on how a .NET engineer builds software application and then uses the IDE and language practices to make the application scalable, more readable, easy to maintain, less verbose, well documented, and less in published archive size. Chapter 2 looks at some of the improvements to the C# language in the 14th version and how that impacts the .NET 10 applications. In that chapter, you will learn about the new constructs announced as part of the language. Then, from there we will build the most used concepts of the .NET framework: web development. In Chapter 3, I will help you understand how ASP.NET has evolved into one of the most scalable, elastic, developer-friendly frameworks on the planet. I will use the examples and real hands-on demonstrations using the Visual Studio (and Visual Studio Code) IDE to showcase how to build web applications. Throughout the chapter, you will learn how to build microservices that are well-integrated with each other using common communication patterns, such as HTTP, message bus, queue, etc. Chapter 3 and onward takes a more hands-on approach to guide you through the application development practices in .NET 10 and use the features of the framework and the language to enhance the developer as well as the customer experience. .NET 10 is not just about building web applications, or console applications. Using .NET 10 you can build, manage, and maintain your enterprise’s data services and sources. The Entity Framework offers services and features that you can use to design, deploy, maintain, update, debug, and fine-tune the data layer for your enterprise. Even if you do not want to use ASP.NET for the web application, you can use the Entity Framework to build the data layer. Entity Framework offers a code-first and the database-first approach to connect your database and the .NET code. In Chapter 4, we will take a look at the code- first approach to design the database schema, test it, and then create the migrations to deploy the schema on a production cluster. You will also learn the new features that are introduced with the latest version of Entity Framework for .NET 10. Entity Framework can be used for web applications and for native offline applications such as WPF or Windows Forms. Moving onward, in Chapter 5, I will demonstrate how to build Windows applications using .NET 10. Microsoft has announced its plans to offer a cross-platform solution to building the GUI applications. For now, the GUI features are limited to the Windows platform only. The WPF framework is open sourced and has received a lot of community interactions and contributions over the past years. You will learn how to build the Desktop applications that connect to your web services and Web APIs written in ASP.NET Core. I will also demonstrate what .NET 10 has in store for the Windows Forms lovers. Windows Forms is a very old ChapTEr 1 .NET ECosysTEm
Page
20
5 technology but very impressive in what it has to offer. You can build a basic Windows GUI application that captures data from a Web API and shows the result in a list in under one hour and deploys it to your customers. WPF takes the GUI performance a step ahead, and you will learn how to use the WPF framework to build applications that make use of the best of the .NET 10 and the DirectX framework. Another interesting area that .NET provides a lot of services to is the mobile development. The Xamarin framework that Microsoft has provided to the developers is powerful. It has a powerful engine that helps build native applications on all the major platforms, from Windows, to Android, to iOS or macOS. Xamarin has evolved into the Multiplatform App UI, simply called MAUI, which aims to bring the XAML experience on all the platforms, cross-platform, and supports Windows, macOS, Android, etc. When using the MAUI, your .NET code can provide native experiences for your GUI applications on every platform. In Chapter 6, we will take a deep dive to look at what Xamarin is, how .NET supports mobile applications, and how you can fine- tune the applications. Remember, mobile applications are not just the user interface. A mobile experience requires offline support, various screen resolutions and interfaces, connectivity with the network, and more. Although we will not touch upon all the features, we will look at the most important additions to the framework that make it easier for everyone to deliver their applications at scale and speed. Modern applications are smart. An application often uses a very powerful backend service that responds to every request a user makes. Often that service is integrated with the application and runs on the device itself. If you are into machine learning, you know that Google’s TensorFlow is one of the leading frameworks for machine learning. TensorFlow models can be compressed to run on mobile devices. For the .NET world, for years there have been community contributions that make it possible to train and use the models in .NET applications. I still remember using the Accord.NET framework to train Apriori models to build basic recommender systems. The Accord.NET framework is amazing and offers many algorithms you can use to build models of the type you need. Microsoft has their own machine learning framework, CNTK, but in this book we are not going to dive into Python-based machine learning frameworks. Instead, we will explore the .NET machine learning framework developed and maintained by Microsoft. In Chapter 7, we will explore the machine learning framework ML.NET and see how it helps us build models and train them in our applications. ChapTEr 1 .NET ECosysTEm