Skip to main content

Posts

Showing posts from November, 2024

C# 13–Implicit index access

New features keeps getting added to C#. With the release of C# 13 as part of .NET 9, you can now use the implicit index operator, ^ , to initialize a collection in reverse order. Before C# 13, you had to index elements from the front when using an object initializer. With the introduction of this operator, you get better readability and it  can help avoid potential off-by-one errors. More information What's new in C# 13 | Microsoft Learn

Autonomy and loose coupling are not only an important characteristic for a software architecture

A utonomy in software design refers to the ability of a system or component to operate independently, making decisions and performing tasks without requiring other components or systems. Autonomy goes hand in hand with loose coupling , limiting the number of dependencies between components. These concepts are crucial for creating systems that are resilient, adaptable, and capable of handling complex tasks in dynamic environments. But could we apply the same concepts outside software design? Let's find out... Some observations If I showed you the following component diagram; what would be some observations, you could make?   Here are some of mine: Information is flowing up from components B, C and D to A. Probably there is some centralized decision making where most of the power is residing in component A. There is a high dependency on component A inside the system. Although without extra details we can misinterpret this diagram, but the risk exists that the co...

Powershell - The profile for the user is a temporary profile

Today I investigated an issue we had in one of our build pipelines. For an unknown reason the build suddenly started to fail. In the build logs we found the following error message: ============================================================================== Generating script. Arguments passed sanitization without change. Formatted command: . 'D:\b\2\_work\135\s\Certificates\Import-PfxCertificate.ps1' -PfxFilePath ***2024.pfx -Password *** ========================== Starting Command Output =========================== "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\b\2\_work\_temp\e3fa7d9e-bd6e-490f-8f71-182a958e03d7.ps1'" Importing store certificate 'D:\b\2\_work\135\s\Certificates\***2024.pfx'... Exception calling "Import" with "3" argument(s): "The profile for the user is a temporary profile. ...

Creating a dependency graph using Github Copilot

Today I was in a meeting with 2 colleagues where we were discussing a specific solution. We were investigating which component had dependencies on which other component to find a way to simplify the architecture and limit the number of dependencies. After the meeting I wondered if Github Copilot could help. I opened the solution in Visual Studio and tried a first prompt: Create me a mermaid diagram showing all projects with their dependencies That didn’t resulted in what I hoped for. By default Visual Studio doesn’t automatically include context. Let’s fix that by adding @workspace: That look’s promising! Let’s copy the result over to a mermaid visualizer tool: Exactly what I was looking for. Nice!

Trust & Inspire instead of Command & Control

I have been in a leadership role for many years and had the opportunity to follow multiple leadership trainings. These trainings all agree that good leadership does not come from a Command & Control mindset. Despite this knowledge I still see some leaders fall back to this mindset. They rely heavily on authority, directives, and the carrot-and-stick approach—rewarding compliance and punishing deviation. While these tactics may yield short-term results, they fail to unlock the true potential of individuals and teams. While authority, directives, and the carrot-and-stick approach may yield short-term results, they fail to unlock the true potential of individuals and teams. I believe in another model where leaders start from a Trust & Inspire mindset. The core idea is to move away from the traditional Command & Control approach by focusing on empowering and inspiring individuals rather than directing and managing them through authority and compliance. Remark: One ...

.NET 8 upgrade - AuthenticationHandler

I know, I know, .NET 9 is released but I’m still helping one of my customers to move all workloads to .NET 8 first. Today we got a compiler error after upgrading our authentication code to .NET 8: 'ISystemClock' is obsolete: 'Use TimeProvider instead.' 1>C:\projects\IAMCore\IAM.Loket\IAMApiKeyAuthenticationHandler.cs(21,13,21,52): warning CS0618: 'AuthenticationHandler<IAMApiKeyAuthenticationOptions>.AuthenticationHandler(IOptionsMonitor<IAMApiKeyAuthenticationOptions>, ILoggerFactory, UrlEncoder, ISystemClock)' is obsolete: 'ISystemClock is obsolete, use TimeProvider on AuthenticationSchemeOptions instead.' Sidenote: I know that this is a warning, but we got ‘ Treat warnings as errors enabled’, a good practice I would recommend everyone to activate on their projects. Here is the original code: ISystemClock was an old abstraction to help during testing. It was never promoted as an official feature. With the release of .NE...

NU1803–NuGet requires HTTPS sources

Today I had to make an update in an old application that was still based on .NET 4.8. When trying to build the application I got the following warning message: NU1803 – NuGet requires HTTPS sources. When going to the NuGet Package Manager in Visual Studio I got a similar warning: The clean solution is switch to an HTTPS based URL. For this application I just removed the old HTTP based package source from my nuget.config file as it was no longer used. If you are absolutely certain you can trust the HTTP source, you can opt out of this warning by setting allowInsecureConnections to true for this package source: More information NuGet Warning NU1803 | Microsoft Learn

.NET Upgrade Assistant now supports upgrading to Centralized Package Management

Centralized package management in Visual Studio is a feature that allows you to manage NuGet package dependencies for multiple projects from a single location. This is particularly useful for large solutions with many projects, as it simplifies the process of keeping package versions consistent across the entire solution. To enable centralized package management, you need to create a Directory.Packages.props file at the root of your repository and set the MSBuild property ManagePackageVersionsCentrally to true . Inside this file, you define the package versions required by your projects using <PackageVersion /> elements. For each project, you then define a <PackageReference /> but omit the Version attribute, as the version will be obtained from the corresponding <PackageVersion /> item. Although this is not that much work, if you find this still too cumbersome I have some good news for you; with the latest release of the .NET Upgrade Assistant, you can let t...

VISUG XL - Azure Static Web Apps

Hello everyone, I hope that when you are reading this post, you are doing it live from VISUG XL 2024 where I'm giving a presentation about Azure Static Web Apps. During this presentation I show(ed) a lot of the great features that Azure Static Web Apps has to offer. In case you have missed the presentation or you want to get more details, I can recommend to check out the full blog series that I created about Azure Static Web Apps: Part I - Using the VS Code Extension Part II - Using the Astro Static Site Generator Part III  – Deploying to multiple environments Part IV – Password protect your environments Part V – Traffic splitting Part VI – Authentication using pre-configured providers Part VII – Application configuration using staticwebapp.config.json Part VIII – API Configuration Part IX – Injecting snippets Part X – Custom authentication Part XI – Authorization Part XII -  Assign roles through an Azure function Part XII...

NU1301–Unable to load the service index for source

Today a colleague contacted me because she got an error when trying to build a specific solution inside Visual Studio. The compilation process failed on contacting the internal Azure DevOps Artifacts nuget feed. Instead she got the following error message: NU1301 Unable to load the service index for source  I tried to load and build the same project but I couldn’t reproduce the issue. There are multiple reasons why this error message appears. I suggested here to try any of the following: Restart Visual Studio: always a good one to try first Run dotnet restore in Interactive Mode : Run the dotnet restore command in interactive mode can help resolve the issue. Clear NuGet Cache : Sometimes, clearing the NuGet cache can help. You can do this by running the following command in the terminal: nuget locals all -clear Neither of my suggestions seemed to help. In the end she was able to solve the issue by removing the local nuget.config file. As she had the pack...

Using secrets.json in IIS

In the world of software development, safeguarding sensitive data is paramount, especially when it comes to configuration settings that may include passwords, API keys, and connection strings. ASP.NET Core provides a robust mechanism for managing such sensitive data during development through the use of a secrets.json file. This feature is part of a broader configuration system that allows developers to store and retrieve application settings in a variety of ways, including environment variables, command-line arguments, and external files. The secrets.json file is a secure and convenient place to store confidential information that is specific to your development environment. It is not checked into source control, which means your secrets are not exposed when your code is shared or published. Instead, the secrets.json file resides in a system-protected user profile folder on your machine, keeping your secrets outside your main source tree avoiding that you accidently check-in and sha...

Multi model support in Github Copilot

Today I want to point out a new feature that was recently introduced in Github Copilot chat; support for multiple large language models. It is now possible to choose between different models so that you can choose the model that aligns best with the needs you have in your specific project. Models that are supported today are GPT-4o, o1, o1-mini and Claud Sonnet 3.5. Remark: To be exact, I have to point out that Github Copilot was leveraging multiple LLMs already for different use cases. Let me show you how this feature works… VS Code Open Github Copilot Chat inside VSCode Click on the ‘Pick model’ dropdown and select a different model   That’s it! Visual Studio Open Github Copilot Chat inside Visual Studio Click on the ‘Pick model’ dropdown and select a different model   That’s it! Remark: I noticed that the Claud Sonnet 3.5 model is not yet available inside Visual Studio. More information https://github.blog/changelog/20...

.NET Conf 2024 is almost there!

Make sure you are well rested as the next 3 days you'll need all your energy to learn about the latest and greatest in .NET at .NET Conf 2024 , a free virtual event from November 12 until November 14. This year you’ll discover the newest features and enhancements in .NET 9, including cloud-native development , AI integration , and performance improvements .   Join me and many others to learn from the .NET team members and the broader .NET community.  Don't forget to collect your free digital swag , enter your details to win a price bag from the sponsors or participate in the challenge to also win a price. More information .NET Conf 2024 What's new in .NET 9 | Microsoft Learn

Web Deploy - WDeployConfigWriter issue

At one of my customers, we are still (happily) using Microsoft Web Deploy to deploy our web applications to IIS. This works great and is all nicely automated and integrated in our Azure DevOps pipelines. Until the moment it no longer works. Something that happened last month when trying to deploy one of our projects. A look at the web deploy logs showed us the following error message: Web deployment task failed. ((2/11/2024 15:00:08) An error occurred when the request was processed on the remote computer.)(2/11/2024 15:00:08) An error occurred when the request was processed on the remote computer.Unable to perform the operation. Please contact your server administrator to check authorization and delegation settings. Time to contact the server administrator... Unfortunately that’s my team in this case. So let’s investigate. We logged in on the web server and checked the event logs. There we got some extra details: A tracing deployment agent exception occurred that was propagat...

Embracing change requests: a mindset shift

In software development, change requests(CR) often get a bad reputation. As developers and architects it can feel frustrating to have to redesign and change existing features(especially if the change request has a big impact on the existing system). However, we should see them as a positive sign for a product's success, evolution, and continued relevance. Let’s explore why… Reason 1 - Our system is used! The fact that we get a CR means that at least someone tried our system and even better they see value in using it further because they want to improve it. When users ask for changes, it's because they're actively engaging with the software. They’re uncovering real-world use cases and scenarios that may not have been anticipated during initial design. This feedback loop confirms that the software is doing something valuable—and that users believe it can do even more. Reason 2 – We have learned something! Software, by its nature, is built to be flexible and adaptabl...