C# – What is a NullReferenceException, and how to fix it?

A NullReferenceException is a common runtime error which occurs when your code tries to access or manipulate an object or a member of an object, but the object reference is currently set to null (meaning it doesn’t reference any valid object in memory). In other words, you’re trying to perform an operation on something that…

|

Add/Remove TypeInfoResolver to existing JsonSerializerOptions

Starting with .NET 8, the JsonSerializerOptions class features a new TypeInfoResolverChain property in addition to the existing TypeInfoResolver property. With this new property, you are no longer required to specify all the resolvers in the same place, instead, you can add them later as needed. Let’s look at an example: Besides adding new type resolvers…

| |

WPF – Prevent file dialog selection from being added to recents

Files opened or saved using WPF’s file dialogs (OpenFileDialog, SaveFileDialog or OpenFolderDialog) are by default added to the Windows Explorer’s recent files list and can also impact the Recommended section of the Start Menu in Windows 11. To disable this behavior, you can set AddToRecent to false on your dialog before calling the ShowDialog() method….

| |

WPF – Individual dialog states using ClientGuid

A new ClientGuid property, introduced with .NET 8, allows you to uniquely identify dialogs such as the OpenFileDialog and the OpenFolderDialog, with the purpose of storing state – such as window size, position and last used folder – separately per dialog. To benefit from this behavior, configure the ClientGuid of your dialog to a known…

| |

WPF – Limit OpenFileDialog folder tree to a certain folder

Starting with .NET 8, you can constrain the OpenFileDialog and OpenFolderDialog folder tree to a given root folder. You can do so by setting the RootDirectory property on the dialog before calling ShowDialog(). It’s very important to note that this does not limit the selection and the navbar navigation in any way. The user will…

Flutter – NoSuchMethod: the method was called on null

This error occurs when attempting to call a method on a null object reference. No such method exists because the call target is null or unassigned. For instance: will fail with a NoSuchMethod error whenever foo is null. The error will say: NoSuchMethod: the method ‘bar’ was called on null. This is the equivalent of…

WPF OpenFolderDialog on Windows 11 with dark theme.
| |

WPF Open Folder Dialog

.NET 8 introduces a new OpenFolderDialog to Windows Presentation Foundation (WPF). This enables application users to browse and select one or multiple folders. Usage is simple: create a new OpenFolderDialog, provide a Title, and an InitialDirectory. And if you want to allow your users to select multiple folders, set Multiselect to true. Next, a simple…

| |

WPF hardware acceleration in RDP

WPF applications use by default software rendering when accessed over remote desktop, even if the system has hardware rendering capabilities. With .NET 8, a new option is introduced which allows you to opt into hardware acceleration when using the Remote Desktop Protocol. This can result in improved performance and an overall more responsive application. You…

The AI revolution – Should software engineers be afraid for their jobs?

The AI revolution – Should software engineers be afraid for their jobs?

This is a question I get asked often, and it comes both from people whithin the industry as well as others from outside our tiny little circle – people at the start of their careers or people worried I might be out of a job soon. And whenever I try to explain why I’m not…

|

Implementation type Data.AppDbContext can’t be converted to service type Microsoft.AspNetCore.Identity.IUserStore

This exception is thrown when you are building an identity DbContext without providing the user and role stores using AddUserStore and AddRoleStore. You can provide both configurations with a single call to AddEntityFrameworkStores like in the example below: The full exception for reference: System.AggregateException: ‘Some services are not able to be constructed (Error while validating…