System.InvalidOperationException: IDX20803: Unable to obtain configuration from: ‘System.String’

Just a friendly reminder to myself (and for whom it may concern): This error message tends to appear when the ASP.NET API can’t talk to the IdentityServer.

Especially tricky when using an ASP.NET API and IdentityServer4 behind a reverse proxy (like nginx). The external world might be able to talk to the IdentityServer, but the API server / container might need some additional configuration with the internal host:port of the IdentityServer.

Configure ASP.NET Core ports with Kestrel (Linux)

This is something that I have to google all the time. So let’s write it down as a blog-post! 🙂

The following assumes that we are running ASP.NET Core on Linux, without IIS. Tested with .NET 5

Source: StackOverflow

Options

As dotnet CLI parameter

dotnet YouApp.dll --urls http://localhost:3000

Kestrel-section in appsettings.json

"Kestrel": { 
	"EndPoints": { 
		"Http": { 
			"Url": "http://localhost:3000"
		} 
	} 
}

Environment variable (bash)

export ASPNETCORE_URLS=http://localhost:3000

Environment variable (bash, multiple urls)

export ASPNETCORE_URLS=http://localhost:3000\; https://localhost:3001

(Note: The semicolon has to be escaped with a backslash so it won’t be interpreted by the bash shell)

The list is by no means complete. At this moment I am mostly interested in configuration via environment variables for docker/DevOps/automation scenarios.

Angular ssl development certificate expired. How to renew it

You already knew how to make your browser accept your development certificates. But today it stopped playing nicely with your Angular app again. After some trial and error you read the fine-print: Your certificate is expired! 😱

You need a new certificate to get unstuck: Delete the file server.pem in the folder node_modules\webpack-dev-server\ssl

Next time you start up your development server (ng serve –ssl true) a new certifcate will be generated and life is good again. Don’t forget to add the new certificate to the certificate store.

Add development certificate in Chrome browser (Windows)

After not finding a good resoure online and having to ask a colleague here is what he has told me to do:

  • Start the app in the browser. Instead of the app content Chrome displays a security warning “Your connection is not private”
  • Click on the “Not secure” field
  • Click on certificate
  • Select the “Details” tab
  • Click on “copy to file” button. The wizard opens
  • Safe certificate as a file (go with the defaults)
  • Next
  • Use the default format and save to a file of your choice.
  • Open the saved certificate file with doubleclick
  • Go with “Current User” and click next.
  • Add certificate to the windows certificate store. Make sure to select “Trusted Root Certification Authorities”. (Disclaimer: I don’t really like to add dev certificates to that store because they are definitely not CA Authorities, but the other stores do not seem to work. If you find a better way feel free to send me an email or Twitter message)
  • Finish the installation
  • Confirm security warning with yes. (like I said above. Please tell me if you have a better solution)
  • Restart Chrome and try again.
  • Chrome should be happy now, show the lock-symbol instead of the warning and load your application!

VirtualBox CPU Performance Tuning

(corrections 21.07.2020: I have falsely written “Multithreading” instead of “Hyperthreading” in some places)

Because my Windows Server 2019 guest system felt quite sluggish, I first googled (of course! 😉 and then tested myself to improve the performance.

Thanks to a blog entry from Mihai Matei on the topic at hand y had an idea on where to look and I could confirm his findings regarding Hyperthreading.

Here are my test-details, in case you are interested. If not you can jump right to the conclusions at the end of the article.

CPU: Intel 8350U (4 Cores, 8 Threads, 15W TDP)
Host RAM: 32GB
Host OS: Windows 10 Pro (1809) 64 bit
Guest OS: Windows Server 2019
Benchmarking-Tool: CPU-Z

Hyperthreading on (Bios setting on host)

CPU-Z benchmark results on the host

  • SC: 406
  • MC: 2002

    Guest with 4 Cores

  • Observation: Opening Windows Explorer slow
  • CPU-Z-Bench
    • SC: 280 Max
    • MC: 1300 Max

      Guest with 1 Core

  • Observation: Opening Windows Explorer much faster
  • CPU-Z Bench
    • SC: 360
    • MC: 360
    • Note: SC is substantially higher, but MC a lot lower. The GUI feels a lot more responsive with only 1 core assigned.

Hyperthreading off (Bios setting on host)

CPU-Z on the host

  • SC: 411
  • MC: 1540
  • Note: SC performance not changed, but about 25% loss on MC performance.

Guest with 4 Cores

  • Observation:

1) Task manager on guest: 6% (almost idle), task manager on host: 28% for VirtualBox task
2) CPU-Frecuency drops from 3,6 to 2,5 during MC test and goes only back up to 3Ghz during SC. Explanation: CPU seems to throttle because of temperature (monitored with HW Info Tool). Environment temp is about 32 C

  • CPU-Z-Bench
    • SC: 295 Max
    • MC: 1070 Max

Guest with 1 Core

  • Observation: The benchmark does not get 100% CPU, because 18% is eaten up by “System Interrupts” accoring to task manager.
  • CPU-Z Bench
    • SC: 370
    • MC: 360

Guest with 2 Cores

  • Observation: System interrupts low (2%, almost all % used by benchmark)
  • CPU-Z Bench
    • SC: 370
    • MC: 730
    • Note: Best result so far. SC performance still high and MC doubled compared to 1 Core.

Guest with 3 Cores

  • Observation: System interrupts low (2%, almost all % used by benchmark). Looks like 3 cores is not a good idea! 😉
  • CPU-Z Bench
    • SC: 305
    • MC: 660

Conclusion

On my particular system the best setting for my Windows Server 2019 guest are:

  • Host: Disable Hyperthreading in BIOS settings
  • VirtualBox Guest Settings: Assign 2 cores

Due to the switched off hyperthreading some mulithreading performance is lost. But as I am mostly depending on high single-threading performance for compiling tasks it is not an issue.

Depending on your CPU and number of cores available your optimal settings may vary.

Developer and Power User Tools for Windows

Last updated: July 2021

This is a collection of the important tools for development and productivity I currently use (C#, ASP.NET, WPF, JavaScript).

.NET

  • JetBrains Rider
  • Visual Studio 2019
  • LINQPad – Amazing power-tool. Instantly test .NET code snippets, query your database, create and analyse LINQ/Entity framework queries. Most used by me to create, analyse and run LINQ to entities queries. It will show the generated SQL and query you database for you. Great learning utility also. It has a ton of code examples from the book C# 3/4/5/6/7 in a Nutshell.
  • ReSharper – Helps you writing better code. Tons of hints for improvements. Great test-runner. Performance tip: Exclude the ..\AppData\Local\Jetbrains folder from the antivirus realtime-protection.

Web development

  • Chrome DevTools – Debug and analyse your frontend stuff. Some Tips and Tricks.
  • Charles Web debugging proxy – See all HTTP/HTTPS traffic of your app. Especially useful if you debug something that does not run in a browser (.NET app, …).
  • WinSCP – Free SFTP, SCP and FTP client for Windows.
  • Putty – Free SSH client
  • BrowserSelector – Windows tool to open different browsers based on the URL. Great if you are using different browsers for different things. I love it!

Diagrams, UX tools

  • PlantUML – Open-source diagram software. Define as text and compile to images.
  • yEd graph editor – Powerful diagrams, cross-platform
  • tldraw –  Simple drawing tool
  • Miro – Collaboration, charting, Agile, all in one place
  • sequencediagram.org
  • draw.io – Online and Desktop diagramming tool. Intuitive and highly productive
  • Enterprise Architect – Professional UML diagrams. Complete application lifecycle modeling.
  • JustInMind

USB development

  • Zadig – USB driver installation made easy

REST (Web API)

  • Postman – Everything you need to test REST APIs.
  • httpstat.us – Generate different HTTP status code. Simulate delays
  • Mockoon – Multi-Platform API Mock software. Great UI, simple to use and tons of features (dynamic responses, CORS, delays, …)

Editors, file comparison

  • VS Code – powerful, open-source multi-platform editor. Don’t use it too much, since I do most of my work in Visual Studio. But I like to use it for editing certain file types (XML).
  • Notepad++ – My workhorse for analysing log-files, search and anything not done in VS Code or Visual Studio.
  • HxD Hex Editor – Nice hex editor. Can calculate checksums like CRC-16.
  • Beyond compare – Compare files, folders, merge, synchronize. An evergreen in my tool belt for comparing stuff.

Automation

AutoHotKey – Very complex and powerfull tool to automate your windows applications

Database

  • Azure Data Studio – Modern alternative to SSMS. Will be installed alongside SSMS on current versions.
  • SQL Server Management Studio – Create, test, analyse, run queries, edit data, backup and restore databases and much more. In the old times it was a part of SQL Server and now an independent project. Please check Overview of SQL Server Tools and Utilities for related applications you might want to use.
  • LINQPad (see entry in the .NET section)

System tools

  • WinDirStat – Visualize the occupied space on your disk. I use that for deleting crap when the disk is getting full.
  • MiniTool Partition Wizard – Manage partitions, move OS from harddrive to SSD and much more. Many features already available in the free version.
  • CPU-Z – Lightweight and fast tool to check you hardware-configuration and run some basic CPU benchmarks.

Graphics

  • Paint.NET – Free and powerful image editor. When Photoshop is too much (and too expensive).

Media

  • ActivePresenter – Records your screen and microphone. Used it for recording tutorials (screencast for YouTube). It also makes a great tool for helping you test your GUI, as you can record what you are doing and what is happening. When something breaks, you can replay and go back in time. Version 7 did not work for me, better try Version 6 of their program while it’s still available.

Health and productivity

  • OneNote – All my notes, bookmarks, screenshots and complete knowledge bases go into OneNote. Make screenshots, format your entries with simple keyboard-shortcuts without touching the mouse, collaborate on content with notebooks stored on MS SharePoint or OneDrive.
  • EyeLeo – Prevents eye strain. Gentle reminders now and then to get your eyes off the screen.
  • Tomighty Pomodoro timer – Get more done with more breaks. The Pomodoro technique works out great for development. Moving my body every half-hour amps up my creativity and helps me getting unstuck. I prefer to move my body, jog for a couple of minutes. Many times it’s off the screen when the aha-moments hit me.

For a much more extensive list of tools check out the resource from Scott Hanselman. Last time I checked it has been updated in 2014, but still of great value for discovering stuff:

Scott Hanselman’s Ultimate Developer and Power Users Tool List for Windows

Another list by Steve Smith (aka Ardalis), who I admire for his software design and coding skills:

Ardalis – Tools Used

Notes about Live Unit Testing in Visual Studio

MS introduced Live Unit Testing in the Enterprise edition of Visual Studio 2017.

I quite like it. A few notes about some issues I had:

  • Don’t mix testing frameworks (MsTest, NUnit, xUnit). Live testing will use one or another test adapter, but only one at the same time. Depending on which one is active you will have tests excluded from live-testing.
  • Update your references. If you cannot debug your unit-tests anymore with Live Unit Testing enabled, have a look at this support case. You might need to delete your existing project reference to “Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll” and install the NuGet packages MSTest.TestAdapter and MSTest.TestFramework instead.
  • Choose your tests wisely. You might want to exclude your long-running integration tests and other tests from being executed by Live Unit Testing: Right-Click on your test project, go into that “Live Unit Testing” entry and include and exclude what you need to be covered by Live Testing.
  • Included test files not updated automatically. If you have included test-data files in your project that are copied to your Output Directory by the build process: These are not updated automatically. I had to Stop and Start Live Testing in order to access added or updated files.

Hope you find that helpful.

Breakpoint in ASP.NET MVC View not hit when using RazorGenerator

If your breakpoints in an ASP.NET MVC view are not hit: Check if you are using RazorGenerator for this particular view:

Screenshot of ASP.NET MVC view Properties. Custom tool set to RazorGenerator
RazorGenerator enabled for ASP.NET MVC view

Fix: Temporarily disable Razor Generator removing the “RazorGenerator” text from the Custom Tool property. Make sure to put it back in after your debugging session.