Scott Hanselman

How to fix Base System Device Driver issue in Windows 10 and Windows 11

October 26, 2021 Comment on this post [3] Posted in Win10 | Win11
Sponsored By

I had a hard drive die recently so I decided to do a full fresh reinstall of Windows, this time a fresh Windows 11 from a downloaded ISO burned to a USB stick.

Lots of Base System Devices in Device Manager

It was a solid install and everything worked out of the box. I used it for a few days and had no issues, but while poking around I noticed in the Device Manager that there were dozens of Base System Devices that were banged out. Like a TON.

I'd like to get that fixed, so I went to Windows Update but WU said everything was cool.

Since a lot of stuff moved and was redesigned in Windows 11 I went looking for "Windows Update Optional Updates" and it took me a while to find it, even though it's listed right there on Windows Update in Settings.

Windows Update optional updates in Windows 11

Click on Advanced Options. Here you can control things like your Windows Update active hours so it doesn't reboot when you don't want it, etc.

Here you'll see a bunch of Optional Updates. I had like 33 of them.

Lots of Optional Updates in Windows 11

Here's what it looks like when you have a bunch of updates pending. These are Chipset and Motherboard updates.

Optional Updates in Windows Update

I did have to select each of these checkboxes and select Install at the end, but once they were done, I had no banged out (yellow exclamation point) devices in Device Manager.

Hope this helps!


Sponsor: Lob APIs ensure your addresses are deliverable and everything you send arrives at the right place. Add address autocompletion and verification in minutes using React, Vue or Javascript - Try for free!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Parallel.ForEachAsync in .NET 6

October 21, 2021 Comment on this post [6] Posted in DotNetCore | Open Source
Sponsored By

Great tweet from Oleg Kyrylchuk (follow him!) showing how cool Parallel.ForEachAsync is in .NET 6. It's new! Let's look at this clean bit of code in .NET 6 that calls the public GitHub API and retrieves n number of names and bios, given a list of GitHub users:

using System.Net.Http.Headers;
using System.Net.Http.Json;

var userHandlers = new []
{
"users/okyrylchuk",
"users/shanselman",
"users/jaredpar",
"users/davidfowl"
};

using HttpClient client = new()
{
BaseAddress = new Uri("https://api.github.com"),
};
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("DotNet", "6"));

ParallelOptions parallelOptions = new()
{
MaxDegreeOfParallelism = 3
};

await Parallel.ForEachAsync(userHandlers, parallelOptions, async (uri, token) =>
{
var user = await client.GetFromJsonAsync<GitHubUser>(uri, token);

Console.WriteLine($"Name: {user.Name}\nBio: {user.Bio}\n");
});

public class GitHubUser
{
public string Name { get; set; }
public string Bio { get; set; }
}

Let's note a few things in this sample Oleg shared. First, there's no Main() as that's not required (but you can have it if you want).

We also see just two usings, bringing other namespaces into scope. Here's what it would look like with explicit namespaces:

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Threading.Tasks;

We've got an array of users to look up in userHandlers. We prep an HttpClient and setup some ParallelOptions, giving our future ForEach the OK to "fan out" to up to three degrees of parallelism - that's the max number of concurrent tasks we will enable in one call. If it's -1 there is no limit to the number of concurrently running operations.

The really good stuff is here. Tight and clean:

await Parallel.ForEachAsync(userHandlers, parallelOptions, async (uri, token) =>
{
var user = await client.GetFromJsonAsync<GitHubUser>(uri, token);

Console.WriteLine($"Name: {user.Name}\nBio: {user.Bio}");
});

"Take this array and naively fan out into parallel tasks and make a bunch of HTTP calls. You'll be getting JSON back that is shaped like the GitHubUser."

We could make it even syntactically shorter if we used a record vs a class with this syntax:

public record GitHubUser (string Name, string Bio);

This makes "naïve" parallelism really easy. By naïve we mean "without inter-dependencies." If you want to do something and you need to "fan out" this is super easy and clean.


Sponsor: Make login Auth0’s problem. Not yours. Provide the convenient login features your customers want, like social login, multi-factor authentication, single sign-on, passwordless, and more. Get started for free.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Space Cadet Pinball for Windows 95 recompiled for Linux running on Windows 11 as a Linux app under WSLg

October 19, 2021 Comment on this post [16] Posted in Linux | Win11
Sponsored By

Award for longest blog post title ever? Andrey Muzychenko has a great github repository where they decompiled the 25 year old Space Cadet Pinball application from Windows 95/XP and then recompiled it for Linux (and really any platform now that it's portable code!).

NOTE: Because this is a decompilation/recompilation, it doesn't include the original data files. You'll need those from a Windows XP disk or ISO that you'll need to find yourself.

I recently did a YouTube where I showed that Windows 11 runs Graphical Linux Apps out of the box with WSLg.

Here, they've taken a Windows 95 32-bit app and decompiled it from the original EXE, done some nice cleanup, and now it can be recompiled to other targets like Linux.

So, could I go Windows 95 -> Linux -> Windows 11 -> WSL -> WSLg and run this new native Linux executable again on Windows?

If you don't think this is cool, that's a bummer. It's an example of how powerful (and fun) virtualization has become on modern systems!

Pinball under Linux under Windows 11

I just launched WSL (Ubuntu) and installed a few things to compile the code:

sudo apt-get install libsdl2-image-dev
sudo apt-get install libsdl2-mixer-dev
sudo apt install gcc clang build-essential cmake

Then I cloned the repo under WSL and built. It builds into bin and creates a Linux executable.

NOTE: Place compiled executable into a folder containing original game resources (not included).

I am a digital hoarder so I have digital copies of basically everything I've worked on for the last 30 years. I happened to have a Windows XP virtual disk drive from a VM from years ago that was saved on my Synology.

Virtual hard drive from Windows XP

I was able to open it and get all the original resources and wav files.

Pinball resources

Then I copy all the original resources minus the .exe and then run the newly built Linux version...and it magically pops out and runs on Windows...as a graphical Linux app.

3D Pinball for Windows

Amazing! Have fun!


Sponsor: Make login Auth0’s problem. Not yours. Provide the convenient login features your customers want, like social login, multi-factor authentication, single sign-on, passwordless, and more. Get started for free.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Dotnet could not execute because the application was not found or a compatible .NET SDK is not installed

October 07, 2021 Comment on this post [0] Posted in DotNetCore
Sponsored By

I ran into this interesting issue where my System PATH environment variables got out of order. I ran "dotnet --version" and saw an error I'd not seen before. Dotnet "Could not execute because the application was not found or a compatible .NET SDK is not installed." What's that?

How did I diagnose this?

dotnet can't run because the application was not found

From the command prompt, I typed "where dotnet" to ask cmd.exe "which dotnet.exe are you offering me and in what order?" You would use the which command in Linux, the where command in DOS, and the more explicit where.exe dotnet on PowerShell.

Here I can see that Program Files (x86) has a dotnet.exe that is FIRST in the Path before the x64 version I expected.

Digging into GitHub I can see that the bug has been fixed but it's good to know how things get into a weird state and how easy it is to fix. In this case, I just swapped (or removed) the x86 and x64 (native architecture) paths in my System PATH via the environment variables UI in Windows. Just type Start and Environment Variables, click it, and then Double Click (or Edit) the PATH variable for a nice UI experience. You can even "move up and move down" within that UI - far nicer than editing a text file.

This can happen when you install a 32-bit .NET SDK on a 64-bit system and the last one in wins. In my case, I don't need a 32-bit host at all in my PATH so I ended up just removing it from my PATH completely.

Hope this helps you if you hit it and glad it's fixed.


Sponsor: YugabyteDB is a distributed SQL database designed for resilience and scale. It is 100% open source, PostgreSQL-compatible, enterprise-grade, and runs across all clouds. Sign up and get a free t-shirt!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Shrink your WSL2 Virtual Disks and Docker Images and Reclaim Disk Space

October 05, 2021 Comment on this post [8] Posted in Docker | Linux
Sponsored By

Docker Desktop for Windows uses WSL to manage all your images and container files and keeps them in a private virtual hard drive (VHDX) called ext4.vhdx.

It's usually in C:\Users\YOURNAME\AppData\Local\Docker\wsl\data and you can often reclaim some of the space if you've cleaned up (pruned your images, etc) with Optimize-Vhd under an administrator PowerShell shell/prompt.

You'll need to stop Docker Desktop by right clicking on its tray icon and choosing Quit Docker Desktop. Once it's stopped, you'll want to stop all running WSL2 instances with wsl --shutdown

Mine was 47gigs as I use Docker A LOT so when I optimize it from admin PowerShell from the wsl\data folder

optimize-vhd -Path .\ext4.vhdx -Mode full

...it is now 2 gigs smaller. That's nice, but it's not a massive improvement. I can run docker images and see that many are out of date or old. If I'm not using Kubernetes I can turn it off and delete those containers as well from the Docker settings UI.

I'll run docker system prune -a to AGRESSIVELY tidy up. Read about these commands before your try yourself. -a means all unused images, not just dangling ones. Don't delete anything you love or care about. If you're worried, docker system is safer without the -a.

Now my Docker WSL 2 VHD is 15 gigs smaller! Learn more about WSL, Windows 11, and WSLg on my latest YouTube!

NOTE: You can now get WSL from the Windows Store! Go get it here and then run "wsl --install" at your command line.

If you want, you can also go find your Ubuntu and other WSL disks and Compact them as well. I only think about this once or twice a year, so don't consider this a major cleanup thing unless you're really tight on space.

Ubuntu WSL disks will be in folders with names like

C:\Users\scott\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState

or

C:\Users\scott\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState

But you will want to look around for yours. Again, back things up and make sure WSL is shutdown first!

Enjoy! REMEMBER - Be sure to back things up before you run commands as admin from some random person's blog. Have a plan.


Sponsor: YugabyteDB is a distributed SQL database designed for resilience and scale. It is 100% open source, PostgreSQL-compatible, enterprise-grade, and runs across all clouds. Sign up and get a free t-shirt!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.