Modernizing .NETpad: (More) Dialog about Dialogs (Premium)

It's been a frustrating week for the .NETpad modernization project. Some of it was self-inflicted. And some was Microsoft's fault.
I take exception
Let me address the latter first, as it's a quicker conversation: Earlier this week, Microsoft made three related developer announcements over two days that I addressed in one post: It released Visual Studio 2022 version 17.11, it released .NET 9 Preview 7, and then it released Visual Studio version 17.12 Preview 1. This seemed straightforward, and since I had been using the pre-release version of Visual Studio 2022 version 17.11 with each preview version of .NET 9 in turn, I dutifully upgraded each on the several PCs I've been using for the project.

As expected, updating the preview version of Visual Studio meant I went from version 17.11 to 17.12. And not that it matters too much, but this is now the baseline for coding to .NET 9: Now that it's in stable, you can't target .NET 9 with Visual Studio 2022 version 17.11 anymore. Not a big deal.

Unfortunately, once I upgraded, nothing worked. The new .NETpad project and all my .NET 9-based side projects would throw an exception when I tried to run them, tied to the weird XAML-based incantation we have to make for now to get .NET 9 working.

Curious. And frustrating. And I was seeing the same error everywhere. I Googled it, of course, but only found results based on the error message generally: What I'm doing is so new and rare there's just not a lot of information out there. So I scoured the announcement posts, and the comments in the announcement posts, to see if I had missed something. My understanding was that the Microsoft had made a single WPF update during the entire .NET 9 development time so far--back in Preview 4 in May--and so it wasn't clear what was happening. And then last night, I saw confirmation that I wasn't the problem: In the GitHub announcement for .NET 9 Preview 7, someone described the exact problem I was seeing. Then, a member of the .NET team created a separate issue for that problem. It wasn't resolved when I went to bed, but I figured (and hoped) it would be in time. I had already lost a day and half to this.

This morning, I opened each of the laptops I've used recently, hoping to find one I hadn't upgraded. And I did, thankfully, so I put that aside, knowing I could use that to keep working if Microsoft didn't fix the issue. But then I checked my email and found some good news: There was and answer to this problem, and it was a simple fix.

Back in May, when Microsoft announced the return of WPF, it explained that one had to add several special lines of XAML code to the App.xaml file in any .NET 9 project that would use the new Windows 11 theming functionality. The key line was:

pack://application:,,,/PresentationFramework.Fluent;component/Resources/Fluent.xaml

And this was, of course, the line that was triggering the exception: Visual Studio couldn't find the resource referenced by that line of code...

Gain unlimited access to Premium articles.

With technology shaping our everyday lives, how could we not dig deeper?

Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.

Tagged with

Share post

Thurrott