❔ 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
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
Can you make a minimal reproduction?
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
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.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
I also have other components listed underneath that namespace which I reference without the need to fully identify them. Its only 2 specific ones.
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.
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.
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
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.
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.