| |

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 Open Folder Dialog
| |

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…

| |

NET 8 – Serializing properties from interface hierarchies

.NET 8 adds support for serializing properties from interface hierarchies. This means that all the properties from all interfaces in the hierarchy will be included in the serialization. The most important thing is where you start. Let’s take the following hierarchy as an example: Now, during serialization, if you pass along a Derived2Impl instance stored…

| |

NET 8 – Deserialize into non-public properties

Similar to serializing into non-public members, you can deserialize into non-public members by providing a constructor with parameters matching the non-public member names and by annotating the non-public members with the JsonInclude attribute. Let’s jump straight to an example: Note how we haven’t annotated PublicProperty in any way and we haven’t included it in the…

| |

NET 8 – How to use JsonStringEnumConverter with native AOT

JsonStringEnumConverter is not compatible with native AOT. To fix that, NET 8 introduces a new converter type JsonStringEnumConverter<TEnum> that is compatible with native AOT. To use the new type, simply annotate your types as follows: Keep in mind: enum deserialization is case insensitive, while serialization can be cusomized via JsonNamingPolicy. What happens if you try…

| |

The type or namespace name InterceptsLocationAttribute could not be found

If you’re just getting started with interceptors, you might be getting one of the following errors: Error CS0246 The type or namespace name ‘InterceptsLocationAttribute’ could not be found (are you missing a using directive or an assembly reference?) Error CS0246 The type or namespace name ‘InterceptsLocation’ could not be found (are you missing a using…

| |

NET 8 – Mark JsonSerializerOptions as readonly

Starting with .NET 8 you can mark JsonSerializerOptions instances as read-only, preventing further changes to the instance. To freeze the instance, simply call MakeReadOnly on the options instance. Let’s take an example: Furthermore, you can check if an instance was frozen or not by checking the IsReadOnly property. Attempting to modify a JsonSerializerOptions instance after…