I am working with MVC3 with razor view.
I am trying to use a model from different project than the mvc3 project,
for same its report compilation error as
CS0246: The type or namespace name 'MyNameSpace' could not be found (are you missing a using directive or an assembly reference?)
as answered in some other posts, I tried to add #using directive or editing web.config in Views folder, but it is still not working.
Could somebody please suggest.
I was missing a assembly to my project. Seems adding the reference wasn't enough.
Correct, adding the reference wouldn't be enough. It needs to be added as an assembly to the project, or the compiler won't be able to find the library.
Related
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
I'm experiencing alot of errors on a big project i've been working on for quite a while now.
Out of nowhere, my VS2017 doesn't recognise any xamarin references.
The project compiled flawlessly a couple of hours ago.
Example
I get 119 errors because of this when i try to compile.
For a solution, i tried to uninstall a nuget package: Xamarin.Android.Support.v4, this resulted in me not being able to install it back because i keep getting these errors when i try to install the package.
I have Xamarin.Forms installed. The bug started not being able to find certain dll files from my .net framework, i tried to solve this by giving direct references to the files, but it kept on not being able to find new dll files.
I always keep a backup on Github for reasons like this, but for some reason, the github project gives me the same bugs! It didn't when i saved it last night. This tells me my environment is screwed up, and for all i've done, i only seem to make it worse, so i don't want to mess up anything more.
Error message:
The type or namespace name 'Thickness' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?
The type or namespace name 'Xamarin' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'XamlCompilationAttribute' could not be found (are you missing a using directive or an assembly reference?)
(This continues for all 119 errors)
New error
Try checking your window's updates. I had the same issue a couple of hours ago and solved it with a system update
try deleting the package folder, and let it restore, Also remove Xamarin.forms nugget then install it again
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.
I 'm using this approach to implement a pluggable architecture in a proof of concept application (ASP.NET MVC 3, using Razor & strongly typed views).
So: i have a normal ASP.NET MVC3 project and a Classlibrary project (the Plugin).
Everything went fine, but as soon as i used strongly typed views (in the Plugin project) i got the following error:
CS0234: The type or namespace name 'ViewModels' does not exist in the namespace 'Plugin1' (are you missing an assembly reference?)
The namespace exists in this assembly, but i have the slight feeling ... somehow it is not loaded...
What do i miss??
You need to add a reference to the plugin project in Web.config.
Can anyone tell me what I need to include besides System.ComponentModel.DataAnnotations to get [AllowHtml] to be recognized? When I add the attribute to a property it tells me the following compiler error:
"The type or namespace name 'AllowHtml' could not be found (are you missing a using directive or an assembly reference?)"
I need to allow html to my field and cannot continue until I get this working. Any help would be greatly appreciated!
Thanks...
As far as I can tell, [AllowHtml] belongs to the System.Web.Mvc namespace.
http://msdn.microsoft.com/en-us/library/system.web.mvc.allowhtmlattribute(v=vs.98).aspx
I had this same issue and took me a while to realise that I was referencing system.web.mvc v2 not v4, so make sure you check the version.
FYI, I had my models stored in a separate project