ReadKey InvalidOperationException application does not have a console

Found my answer in OmniSharp Visual Code docs: https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window Console (terminal) window By default, processes are launched with their console output (stdout/stderr) going to the VS Code Debugger Console. This is useful for executables that take their input from the network, files, etc. But this does NOT work for applications that want to read from … Read more

Is there a built in way of using snake case as the naming policy for JSON in ASP.NET Core 3?

Just slight modification in pfx code to remove the dependency on Newtonsoft Json.Net. String extension method to convert the given string to SnakeCase. public static class StringUtils { public static string ToSnakeCase(this string str) { return string.Concat(str.Select((x, i) => i > 0 && char.IsUpper(x) ? “_” + x.ToString() : x.ToString())).ToLower(); } } Then in our … Read more

How to compile .NET Core app for Linux on a Windows machine

Using dotnet build command, you may specify –runtime flag -r|–runtime < RUNTIME_IDENTIFIER > Target runtime to build for. For a list of Runtime Identifiers (RIDs) you can use, see the RID catalog. RIDs that represent concrete operating systems usually follow this pattern [os].[version]-[arch] Fo example, to build a project and its dependencies for Ubuntu 16.04 … Read more

No service for type ‘Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]’ has been registered

This usually happens in the _LoginPartial.cshtml or _ManageNav.cshtml razor view. Eg. @inject UserManager<IdentityUser> userManager Must be changed to @inject UserManager<MyUserStore> userManager The same applies to SignInManager. When registering your own MyUserStore (bad name, should be MyUser) for the AspNetCore Identity, the UserManager<> type will be registered to the ServiceCollection as UserManager<MyUserStore>. Whenever you want to … Read more

Replace service registration in ASP.NET Core built-in DI container?

This is simple using the Replace(IServiceCollection, ServiceDescriptor) method from the ServiceCollectionDescriptorExtensions class. // IFoo -> FooA services.AddTransient<IFoo, FooA>(); // Replace // IFoo -> FooB var descriptor = new ServiceDescriptor( typeof(IFoo), typeof(FooB), ServiceLifetime.Transient); services.Replace(descriptor); See also: ServiceDescriptor constructors