C
C#14mo ago
Pingu

❔ Blazor Project won't compile - Previously did without any changes.

Hi, I have a blazor project, which previously compiled and ran without issue. My last commit was submitted to source control, which built and published my website as part of the CI/CD step, and all without issue. Having come back to the project, I am getting errors that it can't recognise a 2 types, however when in the files referenced, I can see what types they are. Their namespace is referenced from the main _imports.razor file, and to check I have tried copying the entire contents of said imports file (all the usings) to the top of the effected pages, and get the same errors. I have closed VS, deleted the .vs folder and the bin and obj folders. I restarted my PC. Nothing has worked. The types it seems to not be able to recognise are RegistrationWindow and ExtensionWindow. I am attempting to build the exact same project that previously built without issues a few days ago, AND which my CI/CD process managed to build and compile. I've not knowingly updated anything my end, and my git client shows that no files have changed at all, so there is no reason I can tell for it to not compile. And Nothing I can do to rid the errors. My project is in .net6 (I have plans to upgrade to .net7 in the future, but not for now). I really cannot tell why this is happening, or how to sort it... I have tried re-cloning the project into a different folder and I still get the compilation error. The types exist, their namespaces referenced... I just don't understand... A similar project using a similar setup still compiles without issue...
11 Replies
friedice
friedice14mo ago
I had this similar issue happen to me last week at work as well. The issue was updating visual studio to the latest, as for some reason implicit usings didn't work as intended. Our workaround was to just use the full name and location of our classes Everything still compiled fine on my device as I was the only one that didnt update VS, although I'm unsure if downgrading VS version could work as I have never tried that
Mayor McCheese
Mayor McCheese14mo ago
Can you make a minimal reproduction?
Pingu
Pingu14mo ago
Hmm, yes this does seem to work and build succeeds with it. Have had a think and now that you mention it, I did upgrade VS to the latest, and must fall inbetween last time I built this project without issue and now. I can't figure out why this would happen, I have another similar project that compiles fine. and when I tried downloading the repo into a seperate folder I never opened it in VS, just got the same errors running dotnet build
Pingu
Pingu14mo ago
I honestly wouldn't know where to begin - I have other projects that are similar to this (use an identical starting template) that don't seem to have the issue. Does seem to be related to what IceGPT posted though, in effected files specifying the class with entire namespace preceeding allowed me to compile. Weird that it was only for specific classes... BlurFarmWeb.BlazorWasm.Features.Components is listed as a using statement in the main _imports.razor, which encompasses the files effected where I now for some reason need to fully identify them like this.
Mayor McCheese
Mayor McCheese14mo ago
I usually don't use _imports.razor but instead set up my pages/components in the code behind style. There were a number of problems in the preview days of blazor to where we just didn't use it. Now I'm just in the habit of doing that
Pingu
Pingu14mo ago
I also have other components listed underneath that namespace which I reference without the need to fully identify them. Its only 2 specific ones.
Mayor McCheese
Mayor McCheese14mo ago
Creating a minimal reproduction shouldn't be super hard tbh, and it's a worthwhile skill to learn. But then I'm not sure what you mean by you wouldn't know where to start.
Pingu
Pingu14mo ago
As in, I can't figure out why these 2 components need full namespaces to be referenced. And in other similar projects, the issue doesn't exist at all. I can't figure out what makes these components require this in particular.
friedice
friedice14mo ago
likewise, it was strange. Also to note, if your solution was to use full namspace because you updated VS, make sure everyone that works on that project also update VS. It will compile fine locally for person on the lower version of VS, however when the person makes a PR and the code is merged to a pipeline, the build wont compile
Pingu
Pingu14mo ago
Cheers. I'm a solo dev on the project, so no team related issues thankfully. In a fairly recent change (before updating VS), I moved the location of the 2 components causing issues, so I'm wondering if that is somehow a factor... It doesn't make sense that it is because I've deleted the temp files VS creates (.vs, bin, obj) and restarted, so anything weird hanging around should be gone... But these 2 components both were moved from one folder to another, at the same time a few commits previously... And there are other components in their current location being referenced without any issues.
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts
❔ How can I import json file inside a sass file?I have looked around in the web for various solutions and found it could be done easily in javascrip❔ .NET Core 7.0 SDK shown as installed by "apt-get" but not used by "dotnet" commandI am using dotnet-cli and I have been facing this issue with my dotnet installation on Ubuntu Jammy ❔ EF Core Fluent API - Unidirectional one to many relationshipHow can I implement a one to many unidirectional relationship using EF Core fluent API? (Image 1) I❔ Is it a problem to be creating lots of empty lists etc just to avoid null checks?Over thousands of items, is this expensive or a problem? What is a better way to avoid null checks? ❔ Decent terminal UI library or solutionI'm writing a terminal-based application that requires a TUI. I've tried Terminal.Gui but I've found❔ Unable to bind CollectionView to DictionaryWhen binding a `CollectionView` to a Dictionary, MAUI throws a XAML exception of ``` Error: Cannot ✅ How to make program wait before executing next print line?```cs Console.WriteLine("This is line one"); // sleep 2 seconds Console.WriteLine("This is line two"✅ Navigating my window only display the next page's name instead of its contentsI hope you're all well. I got stuck on a WPF XAML problem where my pages wouldn't navigate and afterMaking an identifier for defined generic typeWhy this does work?✅ Array look if in right order?I have this array: ```cs int[] numbers = {1, 3, 4, 2, 6};``` After that array, I have this: ```cs