Questions

C# Switch expressions returning different result

I've switched to C# 8 on one of my projects. And I've been moving all of my `switch` statements to expressions. However I found out that my project started working differently and I've found out that ...

7 Nov at 07:14

ImmutableSortedDictionary range enumeration by key

I was reading about C#'s `ImmutableSortedDictionary` in `System.Collections.Immutable` and thinking about how to apply it in my program. I quite like C++'s `lower_bound` and `upper_bound` (see [here](...

Identity Server 404 after login (stuck on signin-oidc)

I followed the Identity Server 4 documentation to set up an example server on my local machine. My problem is, that after I log in the application gets stuck on "signin-oidc" page and the logs indicat...

Form view designer is not working in Visual Studio 2019 with C# .NET Core 3.1

When I am opening a Visual Studio project with VB.NET then the Form view designer is automatically opened, but when I open a new project with C# .NET Core 3.1 with Windows Forms then it is showing cod...

8 May at 16:32

ServiceStack - Year, Month, and Day parameters describe an un-representable DateTime even using JsConfig

I have looked at multiple resources online, but whatever I try just doesn't seem to work. What am I doing wrong? using directives ``` using ServiceStack; using ServiceStack.Text; using System; using...

Blazor - show confirmation dialog before delete/update?

In the following Blazor (server-side) code snips. How to prompt the confirmation dialog? ``` <tbody> @foreach (var r in lists) { var s = r.ID; <tr> <td>@s</td> ...

5 Nov at 21:38

How to import Microsoft.AspNetCore.Hosting.IWebHostEnvironment?

The following code in my project gets the following error. ``` public static IServiceCollection AddInfrastructure(this IServiceCollection services, IConfiguration configuration, Microsoft.AspNe...

4 Nov at 22:12

Proper way to use DisposeAsync on C# streams

I'm writing a method which asynchronously writes separate lines of text to a file. If it's it deletes the created file and jumps out of the loop. This is the simplified code which works fine... And I...

9 Jul at 19:32

System.Text.Json Merge two objects

Is it possible to merge two json objects like this with `System.Text.Json?` **Object 1** ```js { id: 1 william: "shakespeare" } ``` **Object 2** ```js { william: "dafoe" ...

What memory model is implemented in .NET Core?

The ECMA CLI specification defines a weak memory model. This allows to reorder the command execution order (which is useful for performance). But writing low-level code for such a model is very diffic...

30 Nov at 17:48

Handle change on Autocomplete Component from material ui

I want to use `Autocomplete` component for input tags. I'm trying to get the tags and save them on a state so I can later save them on the database. I'm using functions instead of classes in react. I ...

23 Aug at 10:12

How do I enable http2 in C# Kestrel web server over plain http?

How do I (and is it possible) to enable http2 over plain http in the C# Kestrel web server? All Microsoft documentation indicates that https/TLS is required, but I have services that will be running b...

3 Nov at 17:47

Nullability of reference types in return type doesn't match overridden member

I'm using an API that returns JSON where one of its values can be either `false` or an object. To handle that, I've created a custom [`JsonConverter`](https://learn.microsoft.com/en-us/dotnet/api/syst...

Nullable reference type information not exposed from FirstOrDefault

I wanted to test out the new [nullable reference types](https://learn.microsoft.com/en-us/dotnet/csharp/nullable-references) feature in C# 8.0. I started a new project targeting .NET Core 3.0, enable...

'propertyName' cannot be used as a property on entity type 'typeName' because it is configured as a navigation

I have an entity `user` with the following: ``` public class User { [Key, Required] public int Id { get; set; } public int GenderId { get; set; } public virtual Gender Gender { get; s...

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler

I have a framework (in this instance it's RxSwift) which I've compiled using Xcode 11.0 into the traditional `RxSwift.framework` style package This imported fine into Xcode 11.0 and also 11.1 never h...

1 Nov at 05:57

consume JSON from webhook in C#

Hi I'm looking to create a simple webhook receiver and dump the data into a table. This is for receiving SMS using Zipwhip. Zipwhip will send a post with JSON. Need to receive the JSON and process. ...

Can I combine a gRPC and webapi app into a .NET Core 3.0 in C#?

I am using dot net core 3.0. I have gRPC app. I am able to communicate to it through gRPC protocol. I thought my next step would be add some restful API support. I modified my startup class to add c...

1 Nov at 14:57

403 Message: Legacy People API has not been used in project

Google API is active but give error ; Legacy People API has not been used in project before or it is disabled. Enable it by visiting [https://console.developers.google.com/apis/api/legacypeople.googl...

1 Nov at 19:43

How to differentiate between null and non existing data in JSON in Asp.Net Core model binding?

I want to differentiate between these two json inputs in an action in Asp.Net Core: ``` { "field1": null, "field2": null } ``` and ``` { "field1": null, } ``` I have an ordinary class lik...

Errors when trying to use StackExchange REDIS in Azure Cloud Service Worker Role

I have a solution hosted in Azure that is using ServiceStack.Redis 2.0.601. App Services (Web API) and On-Premise windows services are all working as expected but the Cloud service worker roles are th...

EF Core 3.0 translating string.Equals ordinalIgnoreCase correctly

Before EF Core 3.0 this worked fine (evaluated on server+client): ``` var exists = await _context.Countries.AsNoTracking().AnyAsync(x => x.CountryCode.Equals(country.CountryCode, StringComparison.Ord...

31 Oct at 10:23

How to redirect to a post upon authentication in ServiceStack

Maybe I am trying to do something stupid but... I am attempting to build a ServiceStack OAuth Provide for Azure AD. The redirect URI is passed through by the SS Authentication but I am not sure what...

31 Oct at 03:5

out parameters of struct type not required to be assigned

I've noticed some bizarre behavior in my code when accidentally commenting out a line in a function during code review. It was very hard to reproduce but I'll depict a similar example here. I've got...

31 Oct at 17:6

ASP.NET Core Testing - get NullReferenceException when initializing InMemory SQLite dbcontext in fixture

I have a test fixture in which I initialize my SQLite in-memory dbcontext, shown below: ``` public static MYAPPDBContext Create() { var options = new DbContextOptionsBuilder<MYAPPDBContext>() ...