Eureka moment! Back when I was trying to load Shapediver for DP’s script, it said I needed to change the NET runtime from NETCore to NETFramework. Although I uninstalled Shapediver, I didn’t set the runtime back to NETCore. I’ve done this and the crashes stop.
I’ll leave it to McNeel to say whether failing under NETFramework is a bug.