Since a few week I’ve been playing around with preview builds of .NET MAUI.
Installing MAUI Preview 8
A couple of days ago Microsoft released the latest preview version of MAUI: preview 8. Although I’m pretty sure I’ve followed every step of the installation guide, including uninstalling earlier versions of Visual Studio 2022 and .NET6, it didn’t work immediately on my machine.
The issue
CS0246: The type or namespace name could not be found
After installing all the bits, I opened up Visual Studio 2022 and created a new MAUI app using the Template:
When building the app, I got the following 2 error messages: The type or namespace name 'IStartup' could not be found
and The type or namespace name 'IAppHostBuilder' could not be found
.
After trying out some stuff, it turned out I was still using the previous .NET MAUI App Template. Apparently the old template wasn’t uninstalled. Still not sure if I missed something or if it was something specific to my machine… Anyway, I managed to fix this issue by running the following cmd command:
dotnet new --install Microsoft.Maui.Templates::6.0.100-rc.1.1608
As I saw the command’s output, my suspicions were confirmed:
Microsoft.Maui.Templates is already installed, version: 6.0.100-preview.7.1345, it will be replaced with version 6.0.100-rc.1.1608.
After re-opening Visual Studio 2022 I also noticed that the .NET MAUI App template got an updated icon (the long awaited MAUI icon) and a ‘New’ badge:
After creating a new MAUI project with this updated template, I was able to successfully build it on my machine! 😎
Running on simulator
I wasn’t able to simulate this, but I noticed that the first time I wanted to run my newly created MAUI App on an Android simulator that not much happened. I’d see Visual Studio telling me the build was successful, but the app wasn’t launched on the simulator. In order to fix this, you need to make sure that the ‘Deploy’ flag is checked in your Configuration Manager.
I haven’t seen this missing flag since, but if somebody would run into it and doesn’t immediately know what to do: you’re welcome! 🙂
September 20, 2021 at 3:02 pm
I’m having the same type/namespace errors! I ran the same command, which did run an update, but the error persists! Such a nuisance!
September 20, 2021 at 3:40 pm
That is strange, David! Make sure after you ran the command that you close VS2022, re-open it and create a new MAUI project using the new Template (do you see the updated icon?).
September 22, 2021 at 6:37 pm
I had the same problem , i did exactly what you said, it did work , new colored Icons and everything seems to work fine.
Thank you