Deleted files gives CS0246 compiler error in VS2022 - visual-studio

I've added 3 default Blazor projects to my solution.
Blazor WebAssembly1
Blazor WebAsssembly2
Blazor Server
The first WebAssembly project is converted to a razor library in order to share code between server and webassembly projects. I also deleted the default pages like FetchData.razor and such.
On compilation I still get compile error on this (the app runs fine though), and I can't seem to resolve them. I've search through the entire solution but can't find any of the files that results in the compile errors.
How to locate the reason for the errors and remove the references? The files are deleted from the project.
Example of compiler error:
CS0246 The type or namepace 'WeatherForecastService' could not be found (are you missing a using directive or an assembly reference?)

The errors in FetchData indicate a problem with the using statements.
Try to check if you have global using, try to remove and declare explicit in the razor page.
Check your CSPROJ and verify the project type, in the RCL the type must be:
<Project Sdk="Microsoft.NET.Sdk.Razor">
In the RCL you haven't a Program/App structure, you have only components and wwwroot elements.
My RCL is composed as follow:
I have also a _Imports.razor with:
#using Microsoft.AspNetCore.Components.Web
...

The issue resolved itself when I restarted Visual Studio.
Sorry for the wild goose chase

Related

Dotnetnuke 8 module development error in visual studio 2013

I have successfully installed DNN 8 and all configuration.
i am also referring video to develop module in visual studio.
https://www.youtube.com/watch?v=AKCYRPuoXF4
when i am trying to build the project then
error comes like:
Error 17 The type or namespace name 'DotNetNuke' could not be found
(are you missing a using directive or an assembly
reference?) C:\websites\dnndev.me\DesktopModules\MyDNNModule\MyDNNModuleModuleSettingsBase.cs 13 7 MyDNNModule
Please help to solve that.
thank you in advance.
Working with DNN8, sometimes I get a set of errors with message
The type or namespace name 'DotNetNuke' could not be found (are you
missing a using directive or an assembly reference?)
, probably 10 or 15 of them, and all located on top of one ascx file. (My dotnetnuke.dll is correctly placed in DNN's bin folder). Taking a better look (scroll down!), I can see that - except them - there are some more error messages (maybe just one of them), and that those additional errors are perfectly clear and logical. So I correct my source code in order to avoid those additional messages, and when I do that - those problematic messages also disappear!
In my case it took me a while to find the solution to this problem, since it only got triggered when I made a change to the View.ascx file.
You need the Visual Studio project to target framework to 4.5 instead of 4.5.1.
I got this solution from here.
Make sure to add a Reference to dotnetnuke.dll in the c:\websites\dnndev.me\bin folder
I honestly haven't done anything with DNN 8 CTP yet, I would stick with 7.4.1 until 8 is official released.

Error building DataAnnotationsModelBinder project to get the Microsoft.Web.Mvc.DataAnnotations.dll

I am refering to the "Validation with Data Annotations tutorial" here http://www.asp.net/mvc/tutorials/older-versions/models-(data)/validation-with-the-data-annotation-validators-cs for my database first MVC3 project. I downloaded the DataAnnotationsModelBinder project but having difficulty building it. It throws following errors:
Error 1 'System.Web.Mvc.IValueProvider' does not contain a definition for 'DoesAnyKeyHavePrefix' and no extension method 'DoesAnyKeyHavePrefix' accepting a first argument of type 'System.Web.Mvc.IValueProvider' could be found (are you missing a using directive or an assembly reference?) C:\XYZ\DataAnnotationsModelBinder\src\DataAnnotationsModelBinder.cs 47 17 Microsoft.Web.Mvc.DataAnnotations
Error 2 Metadata file 'C:\XYZ\DataAnnotationsModelBinder\src\bin\Debug\Microsoft.Web.Mvc.DataAnnotations.dll' could not be found Microsoft.Web.Mvc.DataAnnotations.Tests
Am I missing anything? I tried using VS2008 as well as VS 2010.
Please help.
I'm assuming that you have some missing references, so you need to include the missing references in the project.
You can do this by right clicking the references folder and add them manually. (see image)
Refrences - image
You should not use the DataAnnotationsModelBinder with MVC3. The DefaultModelBinder class already contains all of the logic that was present in the DataAnnotationsModelBinder sample you have linked to.
You probably need to add a reference to System.Web.Mvc 1.0 instead of what you're got at the moment.

System.Data.Linq not loaded in MVC .NET 4.5

I have an ASP.NET MVC4 Web Application project in .NET 4.5 (VS 2012). It is in VB.
It fails loading System.Data.Linq namespace (with all classes and sub-namespaces).
Project has a reference set to System.Data.Linq.dll.
Any ideas where is the problem?
When I try to add Linq2Sql classes, I get such warning:
Namespace or type specified in the Imports 'System.Data.Linq' doesn't contain
any public member or cannot be found. Make sure the namespace or the type is
defined and contains at least one public member. Make sure the imported element
name doesn't use any aliases.
and such errors:
System.Data.Linq.DataContext
But this is just a beginning: if I try to use anything from System.Data.Linq namespace I get an error, for example if I try to use System.Data.Linq.Mapping.DatabaseAttribute, I get such error:
Type 'System.Data.Linq.Mapping.DatabaseAttribute' is not defined.
I had this same problem - and was able to get past it. I'm not entirely sure which of these steps resolved the issue - but this is what I did.
I had originally created the dbml under app_code/gcm
I removed references to System.Data.DataSetExtensions
I deleted the dbml and recreated it outside of the app_code folder
I built the project (no errors/warnings)
I moved the dbml back to the app_code folder and rebuilt (again no errors/warnings)
Hope that helps you get around this.

Missing a using directive or an assembly reference error when I'm not missing anything

I have a solution with 4 projects. In the first one I reference the other three, not with Browse, but with Add reference->Project tab.
I have all three using statements in the beginning.
The program works fine. I tested it and it works. But I'm not able to build it.
I get the error "Missing a using directive or an assembly reference".
None of my projects are on client profile. (I think .Net 2.0 doesn't even have client profile).
Why is VS doing this? How to resolve it?
Clean build was the solution. Duh.

Visual Studio namespace errors after deleting userControls

Really Visual Studio can be so annoying sometimes...
I did nothing else than deleting 3 UserControls in a folder. Since that time I get a error message I do not get rid of. Whatever I do I can not build successfully my project.
I did not touch the SchoolAdministrationUC.xaml file , but I deleted 3 other UserControls also located in the path: TBM\View\SchoolclassAdministration\
Error message from VS:
Error 1 The type or namespacename "SchoolclassAdministration" is in namespace "TBM.View" not available. (missing assembly reference?) E:\TBM\obj\x86\Debug\View\SchoolclassAdministration\SchoolAdministrationUC.g.cs 33 16 TBM
How do I get rid of error ?
Well, the fact that it shows the obj folder as where the error is, have you tried a clean build? Or a complete rebuild?
Sounds like there is an object out there looking for a non-existent namespace.
Build -> Rebuild Solution
This error comes up when you unwittingly create a new Windows application Project to add the existing code for a class library project in the same project folder. If the original class library project is not compatible with VS or you have any other issue then creating a new class class library is an option.

Resources