App not found in VSCode
Hey Whenever I make a new Blazor Web App in VSCode it gives me this error and fails to run. What do I need to do to fix this
42 Replies
it gives me this error and fails to run.A red squiggly line - Tells much.
The type or namespace name 'App' could not be found (are you missing a using directive or an assembly reference?)
I tell the error in the title "of not being found"
App is also not found in Visual Studio as well
Well, the error is quite clear then, isn't it?
There's no class named
App
Yes. But its the DEFAULT page that is created with the template so why is it there
Why does this not occur with others using Visual Studio but it happens for me on both
Can it compile?
No
I see, usually VSCode bugs out and shows random errors, that is why I asked.
Mind posting the file structure?
Where is App class?
No where
App is created by DEFAULT in the Blazor Template
Tutorial: Get started with Razor Pages in ASP.NET Core
This is the first tutorial of a series that teaches the basics of building an ASP.NET Core Razor Pages web app.
Are you sure you are not looking at old docs?
I personally have not touched web dev so I have no idea what is created and what isn't, but seems like it (docs) does not call that method.
When I create a Blazor Web App in VSCode using the C# Dev Kit OR using Visual Studio Community 2022. It creates "program.cs" with "App" referenced. Both using Dotnet 8.0
I never touched program.cs and it just has it.
Using this code. Does work though
Do you have a file called App.razor?
no
it never created one
wait
It did?
Yea 🤔 but its just HTML stuff
Which .NET version do you use?
8.0
Try creating a new webapp, does it work there?
https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/razor-pages-start?view=aspnetcore-8.0&tabs=visual-studio-code#create-a-razor-pages-web-app
K one sec
Yes but it seems like this is Razor? and not Blazor?
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/integration?view=aspnetcore-8.0#razor-component-integration
Seems like the API is for Razor pages only (?), you are mapping for razor components.
For RPages and VMC, IIRC
I am confused as I had this working but now its not working at all.. and not even in Visual Studio. Ugh
Aight, do you want to create a Blazor WASM, Blazor Server, or just mixed Blazor project with the backend server?
For class we specifically need a "Blazor Web App"
Right, and creating this project in VS creates incorrect, non-working code?
Or is it only creating it via the
dotnet
CLI that creates incorrect, non-working code?
If so, what is the template you use with dotnet new
?aright I retried it in VS and not code. It works in there but when I load it into VScode it still shows an error
At this point I'm just gonna say "VSCode being VSCode lmao"
I use the command tool in VSCode to "Dotnet: New Project"
Yea but I had it working but now it won't
Aight,
Dotnet: New Project
... I assume it lets you select the template?yea
If so, which template did you pick?
"Blazor Web App"
huh
And this is what creates a non-working project?
it creates the same as VS but it works in VS now 🤷♂️
so its something with VSCode 😦 at this point I just have to swap over for this one class
VSCode never was a great pick for C#
It got slightly less shit thanks to the DevKit extension
Yea but I had it working just fine
until class was like.. use this and there was no fix for it that i could find
Reason why I hate VSCode nr. 5000
After some fucking around I got it to work. It seems like VSCode is just displaying a random error that doesn't exist
I deleted my whole Blazor Web App in my project and created it in VS
Then just loaded it up in VScode
RenoWebApp/Components is where the App.Razor is found
but it doesn't intelisense it